tinus <o112w8r02@sneakemail.com>:

Use RegisterShellHookWindow

svn path=/trunk/; revision=14042
This commit is contained in:
Gé van Geldorp 2005-03-13 23:10:25 +00:00
parent fa4bd57bed
commit 05df4eff43
4 changed files with 41 additions and 5 deletions

View file

@ -17,7 +17,7 @@ TARGET_INSTALLDIR := .
TARGET_CFLAGS := \ TARGET_CFLAGS := \
-D__USE_W32API -DWIN32 -D_ROS_ \ -D__USE_W32API -DWIN32 -D_ROS_ \
-D_WIN32_IE=0x0600 -D_WIN32_WINNT=0x0501 -DWINVER=0x0500 \ -D_WIN32_IE=0x0600 -D_WIN32_WINNT=0x0501 -DWINVER=0x0500 \
-DUNICODE -fexceptions -Wall \ -DUNICODE -fexceptions -Wall -g \
-I../../../include/expat -I../../../include/expat
TARGET_CPPFLAGS := $(TARGET_CFLAGS) TARGET_CPPFLAGS := $(TARGET_CFLAGS)
@ -26,7 +26,7 @@ TARGET_RCFLAGS := -D__USE_W32API -DWIN32 -D_ROS_ -D__WINDRES__
TARGET_SDKLIBS := \ TARGET_SDKLIBS := \
gdi32.a comctl32.a ole32.a oleaut32.a shell32.a expat.a \ gdi32.a comctl32.a ole32.a oleaut32.a shell32.a expat.a \
notifyhook.a ws2_32.a msimg32.a notifyhook.a ws2_32.a msimg32.a user32.a
TARGET_GCCLIBS := stdc++ uuid TARGET_GCCLIBS := stdc++ uuid

View file

@ -55,12 +55,25 @@ TaskBarMap::~TaskBarMap()
TaskBar::TaskBar(HWND hwnd) TaskBar::TaskBar(HWND hwnd)
: super(hwnd) : super(hwnd)
{ {
HMODULE Module;
_last_btn_width = 0; _last_btn_width = 0;
Module = LoadLibraryA("User32.dll");
if (Module && GetProcAddress(Module, "RegisterShellHookWindow")) {
_HasShellHook = TRUE;
} else {
_HasShellHook = FALSE;
if (Module)
FreeLibrary(Module);
}
LOG (_HasShellHook ? L"Has shell hooks.\n" : L"Does not have shell hooks.\n");
} }
TaskBar::~TaskBar() TaskBar::~TaskBar()
{ {
KillTimer(_hwnd, 0); if (!_HasShellHook)
KillTimer(_hwnd, 0);
//DeinstallShellHook(); //DeinstallShellHook();
} }
@ -99,13 +112,22 @@ LRESULT TaskBar::Init(LPCREATESTRUCT pcs)
Refresh(); Refresh();
SetTimer(_hwnd, 0, 200, NULL); if (_HasShellHook)
RegisterShellHookWindow(_hwnd);
else
SetTimer(_hwnd, 0, 200, NULL);
return 0; return 0;
} }
LRESULT TaskBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) LRESULT TaskBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
{ {
static UINT ShellHookNmsg = 0;
if (!ShellHookNmsg) {
ShellHookNmsg = RegisterWindowMessage(TEXT("SHELLHOOK"));
LOG (FmtString(TEXT("Nmsg == %#x"), ShellHookNmsg));
}
switch(nmsg) { switch(nmsg) {
case WM_SIZE: case WM_SIZE:
SendMessage(_htoolbar, WM_SIZE, 0, 0); SendMessage(_htoolbar, WM_SIZE, 0, 0);
@ -145,7 +167,19 @@ LRESULT TaskBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
return (LRESULT)(HWND)_last_foreground_wnd; return (LRESULT)(HWND)_last_foreground_wnd;
default: def: default: def:
return super::WndProc(nmsg, wparam, lparam); if (nmsg == RegisterWindowMessage(TEXT("SHELLHOOK"))) {
LOG(FmtString(TEXT("SHELLHOOK %x"), wparam));
switch (wparam) {
case HSHELL_WINDOWCREATED:
case HSHELL_WINDOWDESTROYED:
case HSHELL_WINDOWACTIVATED:
case HSHELL_REDRAW:
Refresh();
break;
}
} else {
return super::WndProc(nmsg, wparam, lparam);
}
} }
return 0; return 0;

View file

@ -85,6 +85,7 @@ protected:
int _next_id; int _next_id;
WindowHandle _last_foreground_wnd; WindowHandle _last_foreground_wnd;
int _last_btn_width; int _last_btn_width;
BOOL _HasShellHook;
LRESULT Init(LPCREATESTRUCT pcs); LRESULT Init(LPCREATESTRUCT pcs);
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam); LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);

View file

@ -3708,6 +3708,7 @@ BOOL WINAPI RegisterLogonProcess(DWORD,BOOL);
#if (_WIN32_WINNT >= 0x0501) #if (_WIN32_WINNT >= 0x0501)
BOOL WINAPI RegisterRawInputDevices(PCRAWINPUTDEVICE,UINT,UINT); BOOL WINAPI RegisterRawInputDevices(PCRAWINPUTDEVICE,UINT,UINT);
#endif #endif
BOOL WINAPI RegisterShellHookWindow(HWND);
UINT WINAPI RegisterWindowMessageA(LPCSTR); UINT WINAPI RegisterWindowMessageA(LPCSTR);
UINT WINAPI RegisterWindowMessageW(LPCWSTR); UINT WINAPI RegisterWindowMessageW(LPCWSTR);
BOOL WINAPI ReleaseCapture(void); BOOL WINAPI ReleaseCapture(void);