mirror of
https://github.com/reactos/reactos.git
synced 2024-09-14 06:42:52 +00:00
use DynamicFct for AllowSetForegroundWindow()
svn path=/trunk/; revision=6383
This commit is contained in:
parent
f177ad4810
commit
c42c8aa58a
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<BOOL(WINAPI*)(DWORD dwProcessId)> AllowSetForegroundWindow(TEXT("USER32"), "AllowSetForegroundWindow");
|
||||
|
||||
if (AllowSetForegroundWindow)
|
||||
(*AllowSetForegroundWindow)(processId);
|
||||
|
||||
PostMessage(entry._hWnd, entry._uCallbackMessage, entry._uID, nmsg);
|
||||
}
|
||||
|
|
|
@ -488,6 +488,13 @@ template<typename FCT> 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<typename FCT> struct DynamicLoadLibFct
|
|||
_fct = (FCT) GetProcAddress(_hModule, (LPCSTR)ordinal);
|
||||
}
|
||||
|
||||
DynamicLoadLibFct(LPCTSTR moduleName, LPCSTR name)
|
||||
{
|
||||
_hModule = LoadLibrary(moduleName);
|
||||
|
||||
_fct = (FCT) GetProcAddress(_hModule, name);
|
||||
}
|
||||
|
||||
~DynamicLoadLibFct()
|
||||
{
|
||||
FreeLibrary(_hModule);
|
||||
|
|
Loading…
Reference in a new issue