Startmenu root window. More...
#include <startmenu.h>
Public Types | |
typedef StartMenuHandler | super |
Public Member Functions | |
StartMenuRoot (HWND hwnd, const StartMenuRootCreateInfo &info) | |
void | TrackStartmenu () |
Static Public Member Functions | |
static HWND | Create (HWND hwndDesktopBar, int icon_size) |
Public Attributes | |
HWND | _hwndStartButton |
Protected Member Functions | |
LRESULT | Init (LPCREATESTRUCT pcs) |
LRESULT | WndProc (UINT nmsg, WPARAM wparam, LPARAM lparam) |
virtual void | AddEntries () |
virtual void | ProcessKey (int vk) |
void | Paint (PaintCanvas &canvas) |
void | CloseStartMenu (int id=0) |
close all windows of the start menu popup | |
void | ReadLogoSize () |
UINT | GetLogoResId () |
Protected Attributes | |
SIZE | _logo_size |
Startmenu root window.
Definition at line 364 of file startmenu.h.
typedef StartMenuHandler StartMenuRoot::super |
Reimplemented from StartMenuHandler.
Definition at line 366 of file startmenu.h.
StartMenuRoot::StartMenuRoot | ( | HWND | hwnd, |
const StartMenuRootCreateInfo & | info | ||
) |
Definition at line 1559 of file startmenu.cpp.
References StartMenu::_dirs, WindowHandle::_hwnd, g_Globals, GetDesktopFolder(), and ReadLogoSize().
: super(hwnd, info._icon_size), _hwndStartButton(0) { #ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003) if (!g_Globals._SHRestricted || !SHRestricted(REST_NOCOMMONGROUPS)) #endif try { // insert directory "All Users\Start Menu" ShellDirectory cmn_startmenu(GetDesktopFolder(), SpecialFolderPath(CSIDL_COMMON_STARTMENU, _hwnd), _hwnd); _dirs.push_back(StartMenuDirectory(cmn_startmenu, (LPCTSTR)SpecialFolderFSPath(CSIDL_COMMON_PROGRAMS, _hwnd))); } catch(COMException&) { // ignore exception and don't show additional shortcuts } try { // insert directory "<user name>\Start Menu" ShellDirectory usr_startmenu(GetDesktopFolder(), SpecialFolderPath(CSIDL_STARTMENU, _hwnd), _hwnd); _dirs.push_back(StartMenuDirectory(usr_startmenu, (LPCTSTR)SpecialFolderFSPath(CSIDL_PROGRAMS, _hwnd))); } catch(COMException&) { // ignore exception and don't show additional shortcuts } ReadLogoSize(); }
void StartMenuRoot::AddEntries | ( | ) | [protected, virtual] |
Reimplemented from StartMenu.
Definition at line 1801 of file startmenu.cpp.
References StartMenu::AddButton(), StartMenu::AddEntries(), ICID_EXPLORER, IDC_EXPLORE, and IDS_EXPLORE.
{ super::AddEntries(); AddButton(ResString(IDS_EXPLORE), ICID_EXPLORER, false, IDC_EXPLORE); }
void StartMenuRoot::CloseStartMenu | ( | int | id = 0 ) |
[protected, virtual] |
close all windows of the start menu popup
Reimplemented from StartMenu.
Definition at line 1865 of file startmenu.cpp.
References WindowHandle::_hwnd, StartMenu::_submenu, and StartMenu::CloseSubmenus().
Referenced by TrackStartmenu().
{ if (_submenu) CloseSubmenus(); ShowWindow(_hwnd, SW_HIDE); }
Definition at line 1614 of file startmenu.cpp.
References StartMenuRootCreateInfo::_icon_size, StartMenu::GetWndClasss(), TITLE_STARTMENU, and WINDOW_CREATOR_INFO.
Referenced by DesktopBar::Init().
{ RECT rect; CalculateStartPos(hwndOwner, rect, icon_size); StartMenuRootCreateInfo create_info; create_info._icon_size = icon_size; return Window::Create(WINDOW_CREATOR_INFO(StartMenuRoot,StartMenuRootCreateInfo), &create_info, 0, GetWndClasss(), TITLE_STARTMENU, WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, hwndOwner); }
UINT StartMenuRoot::GetLogoResId | ( | ) | [protected] |
Definition at line 1850 of file startmenu.cpp.
References WindowHandle::_hwnd, IDB_LOGOV, IDB_LOGOV16, and IDB_LOGOV256.
Referenced by Paint(), and ReadLogoSize().
{ WindowCanvas dc(_hwnd); int clr_bits = GetDeviceCaps(dc, BITSPIXEL); if (clr_bits > 8) return IDB_LOGOV; else if (clr_bits > 4) return IDB_LOGOV256; else return IDB_LOGOV16; }
LRESULT StartMenuRoot::Init | ( | LPCREATESTRUCT | pcs ) | [protected, virtual] |
Reimplemented from StartMenu.
Definition at line 1698 of file startmenu.cpp.
References StartMenu::AddButton(), StartMenu::AddSeparator(), g_Globals, ICID_ACTION, ICID_APPS, ICID_CONFIG, ICID_DOCUMENTS, ICID_FAVORITES, ICID_FOLDER, ICID_INFO, ICID_LOGOFF, ICID_RECENT, ICID_RESTART, ICID_SEARCH, ICID_SHUTDOWN, IDC_BROWSE, IDC_DOCUMENTS, IDC_FAVORITES, IDC_LAUNCH, IDC_LOGOFF, IDC_PROGRAMS, IDC_RECENT, IDC_RESTART, IDC_SEARCH, IDC_SETTINGS, IDC_SHUTDOWN, IDC_START_HELP, IDC_TERMINATE, IDS_BROWSE, IDS_DOCUMENTS, IDS_FAVORITES, IDS_LAUNCH, IDS_LOGOFF, IDS_PROGRAMS, IDS_RECENT, IDS_RESTART, IDS_SEARCH, IDS_SETTINGS, IDS_SHUTDOWN, IDS_START_HELP, IDS_TERMINATE, and StartMenu::Init().
{ // add buttons for entries in _entries if (super::Init(pcs)) return 1; AddSeparator(); #ifdef __MINGW32__ HKEY hkey, hkeyAdv; DWORD value, len; if (RegOpenKey(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer"), &hkey)) hkey = 0; if (RegOpenKey(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"), &hkeyAdv)) hkeyAdv = 0; #define IS_VALUE_ZERO(hk, name) \ (!hk || (len=sizeof(value),RegQueryValueEx(hk, name, NULL, NULL, (LPBYTE)&value, &len) || !value)) #define IS_VALUE_NOT_ZERO(hk, name) \ (!hk || (len=sizeof(value),RegQueryValueEx(hk, name, NULL, NULL, (LPBYTE)&value, &len) || value>0)) #endif // insert hard coded start entries AddButton(ResString(IDS_PROGRAMS), ICID_APPS, true, IDC_PROGRAMS); AddButton(ResString(IDS_DOCUMENTS), ICID_DOCUMENTS, true, IDC_DOCUMENTS); #ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003) if (!g_Globals._SHRestricted || !SHRestricted(REST_NORECENTDOCSMENU)) #else if (IS_VALUE_ZERO(hkey, _T("NoRecentDocsMenu"))) #endif AddButton(ResString(IDS_RECENT), ICID_RECENT, true, IDC_RECENT); AddButton(ResString(IDS_FAVORITES), ICID_FAVORITES, true, IDC_FAVORITES); AddButton(ResString(IDS_SETTINGS), ICID_CONFIG, true, IDC_SETTINGS); AddButton(ResString(IDS_BROWSE), ICID_FOLDER, true, IDC_BROWSE); #ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003) if (!g_Globals._SHRestricted || !SHRestricted(REST_NOFIND)) #else if (IS_VALUE_ZERO(hkey, _T("NoFind"))) #endif AddButton(ResString(IDS_SEARCH), ICID_SEARCH, true, IDC_SEARCH); AddButton(ResString(IDS_START_HELP), ICID_INFO, false, IDC_START_HELP); #ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003) if (!g_Globals._SHRestricted || !SHRestricted(REST_NORUN)) #else if (IS_VALUE_ZERO(hkey, _T("NoRun"))) #endif AddButton(ResString(IDS_LAUNCH), ICID_ACTION, false, IDC_LAUNCH); AddSeparator(); #ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003) if (!g_Globals._SHRestricted || SHRestricted(REST_STARTMENULOGOFF) != 1) #else if (IS_VALUE_NOT_ZERO(hkeyAdv, _T("StartMenuLogoff"))) #endif AddButton(ResString(IDS_LOGOFF), ICID_LOGOFF, false, IDC_LOGOFF); #ifdef __REACTOS__ AddButton(ResString(IDS_RESTART), ICID_RESTART, false, IDC_RESTART); #endif #ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003) if (!g_Globals._SHRestricted || !SHRestricted(REST_NOCLOSE)) #else if (IS_VALUE_ZERO(hkey, _T("NoClose"))) #endif AddButton(ResString(IDS_SHUTDOWN), ICID_SHUTDOWN, false, IDC_SHUTDOWN); #ifndef __REACTOS__ AddButton(ResString(IDS_TERMINATE), ICID_LOGOFF, false, IDC_TERMINATE); #endif #ifdef __MINGW32__ RegCloseKey(hkeyAdv); RegCloseKey(hkey); #endif #ifdef _LIGHT_STARTMENU // set the window size to fit all buttons ResizeToButtons(); #endif return 0; }
void StartMenuRoot::Paint | ( | PaintCanvas & | canvas ) | [protected] |
Reimplemented from StartMenu.
Definition at line 1829 of file startmenu.cpp.
References WindowHandle::_hwnd, _logo_size, GetLogoResId(), and StartMenu::Paint().
Referenced by WndProc().
{ MemCanvas mem_dc; ResBitmap bmp(GetLogoResId()); BitmapSelection sel(mem_dc, bmp); ClientRect clnt(_hwnd); int h = min(_logo_size.cy, clnt.bottom); RECT rect = {0, 0, _logo_size.cx, clnt.bottom-h}; HBRUSH hbr = CreateSolidBrush(GetPixel(mem_dc, 0, 0)); FillRect(canvas, &rect, hbr); DeleteObject(hbr); PatBlt(canvas, _logo_size.cx, 0, 1, clnt.bottom, WHITENESS); BitBlt(canvas, 0, clnt.bottom-h, _logo_size.cx, h, mem_dc, 0, ( h<_logo_size.cy ? _logo_size.cy-h : 0) , SRCCOPY); super::Paint(canvas); }
void StartMenuRoot::ProcessKey | ( | int | vk ) | [protected, virtual] |
Definition at line 1873 of file startmenu.cpp.
References StartMenu::_submenu, and StartMenu::CloseOtherSubmenus().
{ switch(vk) { case VK_LEFT: if (_submenu) CloseOtherSubmenus(); // don't close start menu root break; default: super::ProcessKey(vk); } }
void StartMenuRoot::ReadLogoSize | ( | ) | [protected] |
Definition at line 1585 of file startmenu.cpp.
References StartMenu::_border_left, _logo_size, and GetLogoResId().
Referenced by StartMenuRoot(), and WndProc().
{ // read size of logo bitmap BITMAP bmp_hdr; GetObject(ResBitmap(GetLogoResId()), sizeof(BITMAP), &bmp_hdr); _logo_size.cx = bmp_hdr.bmWidth; _logo_size.cy = bmp_hdr.bmHeight; // cache logo width _border_left = _logo_size.cx + 1; }
void StartMenuRoot::TrackStartmenu | ( | ) |
Definition at line 1630 of file startmenu.cpp.
References WindowHandle::_hwnd, _hwndStartButton, StartMenu::_icon_size, CloseStartMenu(), Window::dispatch_dialog_msg(), HandleException(), HWND, Window::pretranslate_msg(), and WINDOW_DYNAMIC_CAST.
Referenced by DesktopBar::ShowStartMenu().
{ MSG msg; HWND hwnd = _hwnd; #ifdef _LIGHT_STARTMENU _selected_id = -1; #endif #ifdef _LIGHT_STARTMENU // recalculate start menu root position RECT rect; CalculateStartPos(_hwndStartButton, rect, _icon_size); SetWindowPos(hwnd, 0, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, 0); ResizeToButtons(); #endif // show previously hidden start menu ShowWindow(hwnd, SW_SHOW); SetForegroundWindow(hwnd); while(IsWindow(hwnd) && IsWindowVisible(hwnd)) { if (!GetMessage(&msg, 0, 0, 0)) { PostQuitMessage(msg.wParam); break; } // Check for a mouse click on any window, that is not part of the start menu if (msg.message==WM_LBUTTONDOWN || msg.message==WM_MBUTTONDOWN || msg.message==WM_RBUTTONDOWN) { StartMenu* menu_wnd = NULL; for(HWND hwnd=msg.hwnd; hwnd; hwnd=GetParent(hwnd)) { menu_wnd = WINDOW_DYNAMIC_CAST(StartMenu, hwnd); if (menu_wnd) break; } if (!menu_wnd) { CloseStartMenu(); break; } } try { if (pretranslate_msg(&msg)) continue; if (dispatch_dialog_msg(&msg)) continue; TranslateMessage(&msg); try { DispatchMessage(&msg); } catch(COMException& e) { HandleException(e, _hwnd); } } catch(COMException& e) { HandleException(e, _hwnd); } } }
LRESULT StartMenuRoot::WndProc | ( | UINT | nmsg, |
WPARAM | wparam, | ||
LPARAM | lparam | ||
) | [protected, virtual] |
Reimplemented from StartMenu.
Definition at line 1809 of file startmenu.cpp.
References WindowHandle::_hwnd, Paint(), ReadLogoSize(), and StartMenu::WndProc().
{ switch(nmsg) { case WM_PAINT: { PaintCanvas canvas(_hwnd); Paint(canvas); break;} case WM_DISPLAYCHANGE: // re-evaluate logo size using the correct color depth ReadLogoSize(); break; default: return super::WndProc(nmsg, wparam, lparam); } return 0; }
Definition at line 373 of file startmenu.h.
Referenced by DesktopBar::Init(), and TrackStartmenu().
SIZE StartMenuRoot::_logo_size [protected] |
Definition at line 379 of file startmenu.h.
Referenced by Paint(), and ReadLogoSize().
ROS Explorer Source Code Documentation
generated on 02.01.2013 by ![]() |