From 338f8e366a62fd1fcfb14c6839bb8e65ee925ad9 Mon Sep 17 00:00:00 2001 From: Martin Fuchs Date: Fri, 2 Jan 2004 15:26:46 +0000 Subject: [PATCH] integrated start menu root with StartMenuHandler svn path=/trunk/; revision=7403 --- .../system/explorer/taskbar/startmenu.cpp | 97 +++++++++---------- .../system/explorer/taskbar/startmenu.h | 51 +++++----- 2 files changed, 73 insertions(+), 75 deletions(-) diff --git a/reactos/subsys/system/explorer/taskbar/startmenu.cpp b/reactos/subsys/system/explorer/taskbar/startmenu.cpp index 8389276cfb0..0d5e2ddf384 100644 --- a/reactos/subsys/system/explorer/taskbar/startmenu.cpp +++ b/reactos/subsys/system/explorer/taskbar/startmenu.cpp @@ -907,9 +907,12 @@ LRESULT StartMenuRoot::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) } -int StartMenuRoot::Command(int id, int code) +int StartMenuHandler::Command(int id, int code) { switch(id) { + + // start menu root + case IDC_PROGRAMS: CreateSubmenu(id, CSIDL_COMMON_PROGRAMS, CSIDL_PROGRAMS, ResString(IDS_PROGRAMS)); break; @@ -963,58 +966,9 @@ int StartMenuRoot::Command(int id, int code) ShowExitWindowsDialog(hwndDesktopBar); break;} - default: - return super::Command(id, code); - } - return 0; -} + // settings menu - -void StartMenuRoot::ShowLaunchDialog(HWND hwndDesktopBar) -{ - ///@todo All text phrases should be put into the resources. - static LPCSTR szTitle = "Create New Task"; - static LPCSTR szText = "Type the name of a program, folder, document, or Internet resource, and Task Manager will open it for you."; - - static DynamicFct RunFileDlg(TEXT("SHELL32"), 61); - - // Show "Run..." dialog - if (RunFileDlg) { -#define W_VER_NT 0 - if ((HIWORD(GetVersion())>>14) == W_VER_NT) { - WCHAR wTitle[40], wText[256]; - - MultiByteToWideChar(CP_ACP, 0, szTitle, -1, wTitle, 40); - MultiByteToWideChar(CP_ACP, 0, szText, -1, wText, 256); - - (*RunFileDlg)(hwndDesktopBar, 0, NULL, (LPCSTR)wTitle, (LPCSTR)wText, RFF_CALCDIRECTORY); - } - else - (*RunFileDlg)(hwndDesktopBar, 0, NULL, szTitle, szText, RFF_CALCDIRECTORY); - } -} - -void ShowExitWindowsDialog(HWND hwndOwner) -{ - static DynamicFct ExitWindowsDlg(TEXT("SHELL32"), 60); - - if (ExitWindowsDlg) - (*ExitWindowsDlg)(hwndOwner); -} - -void StartMenuRoot::ShowRestartDialog(HWND hwndOwner, UINT flags) -{ - static DynamicFct RestartDlg(TEXT("SHELL32"), 59); - - if (RestartDlg) - (*RestartDlg)(hwndOwner, (LPWSTR)L"You selected .\n\n", flags); ///@todo ANSI string conversion if needed -} - - -int StartMenuHandler::Command(int id, int code) -{ - switch(id) { case IDC_SETTINGS_MENU: CreateSubmenu(id, CSIDL_CONTROLS, ResString(IDS_SETTINGS_MENU)); break; @@ -1074,6 +1028,7 @@ int StartMenuHandler::Command(int id, int code) return 0; } + void StartMenuHandler::ShowSearchDialog() { static DynamicFct SHFindFiles(TEXT("SHELL32"), 90); @@ -1090,6 +1045,46 @@ void StartMenuHandler::ShowSearchComputer() (*SHFindComputer)(NULL, NULL); } +void StartMenuHandler::ShowLaunchDialog(HWND hwndDesktopBar) +{ + ///@todo All text phrases should be put into the resources. + static LPCSTR szTitle = "Create New Task"; + static LPCSTR szText = "Type the name of a program, folder, document, or Internet resource, and Task Manager will open it for you."; + + static DynamicFct RunFileDlg(TEXT("SHELL32"), 61); + + // Show "Run..." dialog + if (RunFileDlg) { +#define W_VER_NT 0 + if ((HIWORD(GetVersion())>>14) == W_VER_NT) { + WCHAR wTitle[40], wText[256]; + + MultiByteToWideChar(CP_ACP, 0, szTitle, -1, wTitle, 40); + MultiByteToWideChar(CP_ACP, 0, szText, -1, wText, 256); + + (*RunFileDlg)(hwndDesktopBar, 0, NULL, (LPCSTR)wTitle, (LPCSTR)wText, RFF_CALCDIRECTORY); + } + else + (*RunFileDlg)(hwndDesktopBar, 0, NULL, szTitle, szText, RFF_CALCDIRECTORY); + } +} + +void StartMenuHandler::ShowRestartDialog(HWND hwndOwner, UINT flags) +{ + static DynamicFct RestartDlg(TEXT("SHELL32"), 59); + + if (RestartDlg) + (*RestartDlg)(hwndOwner, (LPWSTR)L"You selected .\n\n", flags); ///@todo ANSI string conversion if needed +} + +void ShowExitWindowsDialog(HWND hwndOwner) +{ + static DynamicFct ExitWindowsDlg(TEXT("SHELL32"), 60); + + if (ExitWindowsDlg) + (*ExitWindowsDlg)(hwndOwner); +} + void SettingsMenu::AddEntries() { diff --git a/reactos/subsys/system/explorer/taskbar/startmenu.h b/reactos/subsys/system/explorer/taskbar/startmenu.h index 41a46cfc123..33855a425f5 100644 --- a/reactos/subsys/system/explorer/taskbar/startmenu.h +++ b/reactos/subsys/system/explorer/taskbar/startmenu.h @@ -226,11 +226,36 @@ typedef BOOL (WINAPI* SHFINDFILES)(LPCITEMIDLIST pidlRoot, LPCITEMIDLIST pidlSav typedef BOOL (WINAPI* SHFINDCOMPUTER)(LPCITEMIDLIST pidlRoot, LPCITEMIDLIST pidlSavedSearch); - /// Startmenu root window -struct StartMenuRoot : public StartMenu + /// Handling of standard start menu commands +struct StartMenuHandler : public StartMenu { typedef StartMenu super; + StartMenuHandler(HWND hwnd) + : super(hwnd) + { + } + + StartMenuHandler(HWND hwnd, const StartMenuCreateInfo& create_info) + : super(hwnd, create_info) + { + } + +protected: + int Command(int id, int code); + + static void ShowLaunchDialog(HWND hwndDesktopBar); + static void ShowRestartDialog(HWND hwndOwner, UINT flags); + static void ShowSearchDialog(); + static void ShowSearchComputer(); +}; + + + /// Startmenu root window +struct StartMenuRoot : public StartMenuHandler +{ + typedef StartMenuHandler super; + StartMenuRoot(HWND hwnd); static HWND Create(HWND hwndDesktopBar); @@ -243,28 +268,6 @@ protected: SIZE _logo_size; void AddEntries(); - int Command(int id, int code); - - static void ShowLaunchDialog(HWND hwndDesktopBar); - static void ShowRestartDialog(HWND hwndOwner, UINT flags); -}; - - - /// Handling of standard start menu commands -struct StartMenuHandler : public StartMenu -{ - typedef StartMenu super; - - StartMenuHandler(HWND hwnd, const StartMenuCreateInfo& create_info) - : super(hwnd, create_info) - { - } - -protected: - int Command(int id, int code); - - static void ShowSearchDialog(); - static void ShowSearchComputer(); };