From 5207a6524efcd89faada4cdd4401da1497f4bdcd Mon Sep 17 00:00:00 2001 From: Martin Fuchs Date: Tue, 26 Aug 2003 15:51:17 +0000 Subject: [PATCH] Implemented Search and Shut Down in startmenu by calling undocumentd shell32 fucntions svn path=/trunk/; revision=5871 --- .../subsys/system/explorer/explorer_intres.h | 1 + .../subsys/system/explorer/explorer_intres.rc | 3 + .../system/explorer/taskbar/desktopbar.h | 35 ++++---- .../system/explorer/taskbar/startmenu.cpp | 85 +++++++++++++++---- .../system/explorer/taskbar/startmenu.h | 13 ++- 5 files changed, 102 insertions(+), 35 deletions(-) diff --git a/reactos/subsys/system/explorer/explorer_intres.h b/reactos/subsys/system/explorer/explorer_intres.h index ae8741dc767..881004684ea 100644 --- a/reactos/subsys/system/explorer/explorer_intres.h +++ b/reactos/subsys/system/explorer/explorer_intres.h @@ -20,6 +20,7 @@ #define IDS_NETWORK 16 #define IDS_CONNECTIONS 17 #define IDS_DRIVES 18 +#define IDS_SEARCH_COMPUTER 19 #define IDI_REACTOS 100 #define IDI_EXPLORER 101 #define IDI_STARTMENU 102 diff --git a/reactos/subsys/system/explorer/explorer_intres.rc b/reactos/subsys/system/explorer/explorer_intres.rc index 8034a6aa9ea..5d38b9549d9 100644 --- a/reactos/subsys/system/explorer/explorer_intres.rc +++ b/reactos/subsys/system/explorer/explorer_intres.rc @@ -106,6 +106,7 @@ BEGIN IDS_NETWORK "Rețea" IDS_CONNECTIONS "Conecții" IDS_DRIVES "Discuri" + IDS_SEARCH_COMPUTER "Search Computer..." END #endif // Romanian resources @@ -363,6 +364,7 @@ BEGIN IDS_NETWORK "Netzwerk" IDS_CONNECTIONS "Verbindungen" IDS_DRIVES "Verzeichnisse" + IDS_SEARCH_COMPUTER "Suche Computer..." END #endif // German (Germany) resources @@ -571,6 +573,7 @@ BEGIN IDS_NETWORK "Network" IDS_CONNECTIONS "Connections" IDS_DRIVES "Drives" + IDS_SEARCH_COMPUTER "Search Computer..." END #endif // English (U.S.) resources diff --git a/reactos/subsys/system/explorer/taskbar/desktopbar.h b/reactos/subsys/system/explorer/taskbar/desktopbar.h index a64ade3bb1d..063cb6e9fc6 100644 --- a/reactos/subsys/system/explorer/taskbar/desktopbar.h +++ b/reactos/subsys/system/explorer/taskbar/desktopbar.h @@ -36,24 +36,25 @@ #define DESKTOPBARBAR_HEIGHT 29 -#define IDC_START 0x1000 -#define IDC_LOGOFF 0x1001 -#define IDC_SHUTDOWN 0x1002 -#define IDC_LAUNCH 0x1003 -#define IDC_START_HELP 0x1004 -#define IDC_SEARCH 0x1005 -#define IDC_SETTINGS 0x1006 -#define IDC_ADMIN 0x1007 -#define IDC_DOCUMENTS 0x1008 -#define IDC_RECENT 0x1009 -#define IDC_FAVORITES 0x100A -#define IDC_PROGRAMS 0x100B -#define IDC_EXPLORE 0x100C -#define IDC_NETWORK 0x100D -#define IDC_CONNECTIONS 0x100E -#define IDC_DRIVES 0x100F +#define IDC_START 0x1000 +#define IDC_LOGOFF 0x1001 +#define IDC_SHUTDOWN 0x1002 +#define IDC_LAUNCH 0x1003 +#define IDC_START_HELP 0x1004 +#define IDC_SEARCH 0x1005 +#define IDC_SEARCH_COMPUTER 0x1006 +#define IDC_SETTINGS 0x1007 +#define IDC_ADMIN 0x1008 +#define IDC_DOCUMENTS 0x1009 +#define IDC_RECENT 0x100A +#define IDC_FAVORITES 0x100B +#define IDC_PROGRAMS 0x100C +#define IDC_EXPLORE 0x100D +#define IDC_NETWORK 0x100E +#define IDC_CONNECTIONS 0x100F +#define IDC_DRIVES 0x1010 -#define IDC_FIRST_MENU 0x3000 +#define IDC_FIRST_MENU 0x3000 /// desktop bar window, also known as "system tray" diff --git a/reactos/subsys/system/explorer/taskbar/startmenu.cpp b/reactos/subsys/system/explorer/taskbar/startmenu.cpp index 6a6783e007e..51d2812d2eb 100644 --- a/reactos/subsys/system/explorer/taskbar/startmenu.cpp +++ b/reactos/subsys/system/explorer/taskbar/startmenu.cpp @@ -573,23 +573,24 @@ LRESULT StartMenuRoot::Init(LPCREATESTRUCT pcs) AddSeparator(); // insert hard coded start entries - AddButton(ResString(IDS_PROGRAMS), 0, true, IDC_PROGRAMS); - AddButton(ResString(IDS_FAVORITES), 0, true, IDC_FAVORITES); - AddButton(ResString(IDS_DOCUMENTS), 0, true, IDC_DOCUMENTS); - AddButton(ResString(IDS_RECENT), 0, true, IDC_RECENT); - AddButton(ResString(IDS_SETTINGS), 0, true, IDC_SETTINGS); - AddButton(ResString(IDS_ADMIN), 0, true, IDC_ADMIN); - AddButton(ResString(IDS_DRIVES), 0, true, IDC_DRIVES); - AddButton(ResString(IDS_NETWORK), 0, true, IDC_NETWORK); - AddButton(ResString(IDS_CONNECTIONS),0,true, IDC_CONNECTIONS); - AddButton(ResString(IDS_SEARCH), 0, false, IDC_SEARCH); - AddButton(ResString(IDS_START_HELP),0, false, IDC_START_HELP); - AddButton(ResString(IDS_LAUNCH), 0, false, IDC_LAUNCH); + AddButton(ResString(IDS_PROGRAMS), 0, true, IDC_PROGRAMS); + AddButton(ResString(IDS_FAVORITES), 0, true, IDC_FAVORITES); + AddButton(ResString(IDS_DOCUMENTS), 0, true, IDC_DOCUMENTS); + AddButton(ResString(IDS_RECENT), 0, true, IDC_RECENT); + AddButton(ResString(IDS_SETTINGS), 0, true, IDC_SETTINGS); + AddButton(ResString(IDS_ADMIN), 0, true, IDC_ADMIN); + AddButton(ResString(IDS_DRIVES), 0, true, IDC_DRIVES); + AddButton(ResString(IDS_NETWORK), 0, true, IDC_NETWORK); + AddButton(ResString(IDS_CONNECTIONS), 0, true, IDC_CONNECTIONS); + AddButton(ResString(IDS_SEARCH), 0, false, IDC_SEARCH); + AddButton(ResString(IDS_SEARCH_COMPUTER),0,false, IDC_SEARCH_COMPUTER); + AddButton(ResString(IDS_START_HELP), 0, false, IDC_START_HELP); + AddButton(ResString(IDS_LAUNCH), 0, false, IDC_LAUNCH); AddSeparator(); - AddButton(ResString(IDS_SHUTDOWN), SmallIcon(IDI_LOGOFF), false, IDC_SHUTDOWN); AddButton(ResString(IDS_LOGOFF), SmallIcon(IDI_LOGOFF), false, IDC_LOGOFF); + AddButton(ResString(IDS_SHUTDOWN), SmallIcon(IDI_LOGOFF), false, IDC_SHUTDOWN); return 0; } @@ -675,14 +676,28 @@ int StartMenuRoot::Command(int id, int code) CreateSubmenu(id, CSIDL_DRIVES); break; - case IDC_LOGOFF: - DestroyWindow(GetParent(_hwnd)); //TODO: show dialog and ask for acknowledge + case IDC_SEARCH: + ShowSearchDialog(); break; - case IDC_SHUTDOWN: - DestroyWindow(GetParent(_hwnd)); //TODO: show dialog box and shut down system + case IDC_SEARCH_COMPUTER: + ShowSearchComputer(); break; + case IDC_LOGOFF: + /* The shell32 Dialog prompts about some system setting change. This is not what we want to display here. + HWND hwndDesktopBar = GetWindow(_hwnd, GW_OWNER); + CloseStartMenu(id); + ShowRestartDialog(hwndDesktopBar, EWX_LOGOFF);*/ + DestroyWindow(GetParent(_hwnd)); + break; + + case IDC_SHUTDOWN: { + HWND hwndDesktopBar = GetWindow(_hwnd, GW_OWNER); + CloseStartMenu(id); + ShowExitWindowsDialog(hwndDesktopBar); + break;} + default: return super::Command(id, code); } @@ -716,6 +731,42 @@ void StartMenuRoot::ShowLaunchDialog(HWND hwndDesktopBar) } } +void StartMenuRoot::ShowExitWindowsDialog(HWND hwndOwner) +{ + HMODULE hShell32 = GetModuleHandle(_T("SHELL32")); + EXITWINDOWSDLG ExitWindowsDlg = (EXITWINDOWSDLG)GetProcAddress(hShell32, (LPCSTR)60); + + if (ExitWindowsDlg) + ExitWindowsDlg(hwndOwner); +} + +void StartMenuRoot::ShowRestartDialog(HWND hwndOwner, UINT flags) +{ + HMODULE hShell32 = GetModuleHandle(_T("SHELL32")); + RESTARTWINDOWSDLG RestartDlg = (RESTARTWINDOWSDLG)GetProcAddress(hShell32, (LPCSTR)59); + + if (RestartDlg) + RestartDlg(hwndOwner, L"You selected .\n\n", flags); //TODO: ANSI string conversion if needed +} + +void StartMenuRoot::ShowSearchDialog() +{ + HMODULE hShell32 = GetModuleHandle(_T("SHELL32")); + SHFINDFILES SHFindFiles = (SHFINDFILES)GetProcAddress(hShell32, (LPCSTR)90); + + if (SHFindFiles) + SHFindFiles(NULL, NULL); +} + +void StartMenuRoot::ShowSearchComputer() +{ + HMODULE hShell32 = GetModuleHandle(_T("SHELL32")); + SHFINDCOMPUTER SHFindComputer = (SHFINDCOMPUTER)GetProcAddress(hShell32, (LPCSTR)91); + + if (SHFindComputer) + SHFindComputer(NULL, NULL); +} + RecentStartMenu::RecentStartMenu(HWND hwnd, const StartMenuFolders& info) : super(hwnd, info) diff --git a/reactos/subsys/system/explorer/taskbar/startmenu.h b/reactos/subsys/system/explorer/taskbar/startmenu.h index c43bb945b06..c71e24e04cd 100644 --- a/reactos/subsys/system/explorer/taskbar/startmenu.h +++ b/reactos/subsys/system/explorer/taskbar/startmenu.h @@ -191,6 +191,13 @@ typedef void (WINAPI* RUNFILEDLG)(HWND hwndOwner, HICON hIcon, LPCSTR lpstrDirec #define RFF_NOSEPARATEMEM 0x20 // Removes the Separate Memory Space check box (Windows NT only). + // declare more undocumented shell32 functions +typedef void (WINAPI* EXITWINDOWSDLG)(HWND hwndOwner); +typedef int (WINAPI* RESTARTWINDOWSDLG)(HWND hwndOwner, LPCWSTR reason, UINT flags); +typedef BOOL (WINAPI* SHFINDFILES)(LPCITEMIDLIST pidlRoot, LPCITEMIDLIST pidlSavedSearch); +typedef BOOL (WINAPI* SHFINDCOMPUTER)(LPCITEMIDLIST pidlRoot, LPCITEMIDLIST pidlSavedSearch); + + // Startmenu root window struct StartMenuRoot : public StartMenu { @@ -205,7 +212,11 @@ protected: LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam); int Command(int id, int code); - void ShowLaunchDialog(HWND hwndDesktopBar); + static void ShowLaunchDialog(HWND hwndDesktopBar); + static void ShowExitWindowsDialog(HWND hwndOwner); + static void ShowRestartDialog(HWND hwndOwner, UINT flags); + static void ShowSearchDialog(); + static void ShowSearchComputer(); SIZE _logo_size; };