diff --git a/reactos/subsys/system/explorer/taskbar/startmenu.cpp b/reactos/subsys/system/explorer/taskbar/startmenu.cpp index 41841fcef95..058547cf763 100644 --- a/reactos/subsys/system/explorer/taskbar/startmenu.cpp +++ b/reactos/subsys/system/explorer/taskbar/startmenu.cpp @@ -104,6 +104,7 @@ HWND StartMenu::Create(int x, int y, const StartMenuFolders& folders, HWND hwndP create_info._folders = folders; create_info._border_top = top_height; + create_info._creator = creator; if (title) create_info._title = title; @@ -238,7 +239,8 @@ LRESULT StartMenu::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) // create a floating copy of the current start menu WindowRect pos(_hwnd); - StartMenu::Create(pos.left, pos.top, _create_info._folders, 0, _create_info._title); + //TODO: do something similar to StartMenuRoot::TrackStartmenu() in order to automatically close submenus when clicking on the desktop background + StartMenu::Create(pos.left, pos.top, _create_info._folders, 0, _create_info._title, _create_info._creator); CloseStartMenu(); } break;} @@ -274,6 +276,9 @@ LRESULT StartMenu::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) break;} case PM_STARTENTRY_LAUNCHED: + if (GetWindowStyle(_hwnd) & WS_CAPTION) // don't automatically close floating menus + return 0; + // route message to the parent menu and close menus after launching an entry if (!SendParent(nmsg, wparam, lparam)) DestroyWindow(_hwnd); @@ -569,8 +574,11 @@ void StartMenu::ActivateEntry(int id, const ShellEntrySet& entries) /// close all windows of the start menu popup void StartMenu::CloseStartMenu(int id) { - if (!SendParent(PM_STARTENTRY_LAUNCHED, id, (LPARAM)_hwnd)) - DestroyWindow(_hwnd); + if (!(GetWindowStyle(_hwnd) & WS_CAPTION)) { // don't automatically close floating menus + if (!SendParent(PM_STARTENTRY_LAUNCHED, id, (LPARAM)_hwnd)) + DestroyWindow(_hwnd); + } else if (_submenu) // instead close submenus of floating parent menus + CloseSubmenus(); } diff --git a/reactos/subsys/system/explorer/taskbar/startmenu.h b/reactos/subsys/system/explorer/taskbar/startmenu.h index ba4e04f1fa3..dd4e9db860f 100644 --- a/reactos/subsys/system/explorer/taskbar/startmenu.h +++ b/reactos/subsys/system/explorer/taskbar/startmenu.h @@ -126,6 +126,7 @@ struct StartMenuCreateInfo StartMenuFolders _folders; int _border_top; String _title; + Window::CREATORFUNC _creator; }; #define STARTMENU_CREATOR(WND_CLASS) WINDOW_CREATOR_INFO(WND_CLASS, StartMenuCreateInfo) @@ -185,6 +186,7 @@ protected: void AddButton(LPCTSTR title, HICON hIcon=0, bool hasSubmenu=false, UINT id=(UINT)-1, DWORD style=WS_VISIBLE|WS_CHILD|BS_OWNERDRAW); void AddSeparator(); + bool CloseSubmenus() {return CloseOtherSubmenus(0);} bool CloseOtherSubmenus(int id); void CreateSubmenu(int id, LPCTSTR title, CREATORFUNC creator=s_def_creator); void CreateSubmenu(int id, int folder, LPCTSTR title, CREATORFUNC creator=s_def_creator); diff --git a/reactos/subsys/system/explorer/taskbar/traynotify.cpp b/reactos/subsys/system/explorer/taskbar/traynotify.cpp index 470b040b1a0..4848c8c97ff 100644 --- a/reactos/subsys/system/explorer/taskbar/traynotify.cpp +++ b/reactos/subsys/system/explorer/taskbar/traynotify.cpp @@ -152,9 +152,11 @@ LRESULT NotifyArea::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) DWORD processId; GetWindowThreadProcessId(entry._hWnd, &processId); -#ifndef __WINE__ // currently no AllowSetForegroundWindow() in Wine - AllowSetForegroundWindow(processId); -#endif + // bind dynamicaly to AllowSetForegroundWindow() to be compatible to WIN98 + static DynamicFct AllowSetForegroundWindow(TEXT("USER32"), "AllowSetForegroundWindow"); + + if (AllowSetForegroundWindow) + (*AllowSetForegroundWindow)(processId); PostMessage(entry._hWnd, entry._uCallbackMessage, entry._uID, nmsg); } diff --git a/reactos/subsys/system/explorer/utility/utility.h b/reactos/subsys/system/explorer/utility/utility.h index 76ddca21ad3..3a315ec8660 100644 --- a/reactos/subsys/system/explorer/utility/utility.h +++ b/reactos/subsys/system/explorer/utility/utility.h @@ -488,6 +488,13 @@ template struct DynamicFct _fct = (FCT) GetProcAddress(hModule, (LPCSTR)ordinal); } + DynamicFct(LPCTSTR moduleName, LPCSTR name) + { + HMODULE hModule = GetModuleHandle(moduleName); + + _fct = (FCT) GetProcAddress(hModule, name); + } + FCT operator*() const {return _fct;} operator bool() const {return _fct? true: false;} @@ -506,6 +513,13 @@ template struct DynamicLoadLibFct _fct = (FCT) GetProcAddress(_hModule, (LPCSTR)ordinal); } + DynamicLoadLibFct(LPCTSTR moduleName, LPCSTR name) + { + _hModule = LoadLibrary(moduleName); + + _fct = (FCT) GetProcAddress(_hModule, name); + } + ~DynamicLoadLibFct() { FreeLibrary(_hModule);