From 05df4eff43eafb086142cd7c58fc174bd334a6ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Sun, 13 Mar 2005 23:10:25 +0000 Subject: [PATCH] tinus : Use RegisterShellHookWindow svn path=/trunk/; revision=14042 --- reactos/subsys/system/explorer/Makefile | 4 +- .../system/explorer/taskbar/taskbar.cpp | 40 +++++++++++++++++-- .../subsys/system/explorer/taskbar/taskbar.h | 1 + reactos/w32api/include/winuser.h | 1 + 4 files changed, 41 insertions(+), 5 deletions(-) diff --git a/reactos/subsys/system/explorer/Makefile b/reactos/subsys/system/explorer/Makefile index 27f6852474c..b0d40a24e3d 100644 --- a/reactos/subsys/system/explorer/Makefile +++ b/reactos/subsys/system/explorer/Makefile @@ -17,7 +17,7 @@ TARGET_INSTALLDIR := . TARGET_CFLAGS := \ -D__USE_W32API -DWIN32 -D_ROS_ \ -D_WIN32_IE=0x0600 -D_WIN32_WINNT=0x0501 -DWINVER=0x0500 \ - -DUNICODE -fexceptions -Wall \ + -DUNICODE -fexceptions -Wall -g \ -I../../../include/expat TARGET_CPPFLAGS := $(TARGET_CFLAGS) @@ -26,7 +26,7 @@ TARGET_RCFLAGS := -D__USE_W32API -DWIN32 -D_ROS_ -D__WINDRES__ TARGET_SDKLIBS := \ 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 diff --git a/reactos/subsys/system/explorer/taskbar/taskbar.cpp b/reactos/subsys/system/explorer/taskbar/taskbar.cpp index c18f1a1c550..91e79068d1c 100644 --- a/reactos/subsys/system/explorer/taskbar/taskbar.cpp +++ b/reactos/subsys/system/explorer/taskbar/taskbar.cpp @@ -55,12 +55,25 @@ TaskBarMap::~TaskBarMap() TaskBar::TaskBar(HWND hwnd) : super(hwnd) { + HMODULE Module; _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() { - KillTimer(_hwnd, 0); + if (!_HasShellHook) + KillTimer(_hwnd, 0); //DeinstallShellHook(); } @@ -99,13 +112,22 @@ LRESULT TaskBar::Init(LPCREATESTRUCT pcs) Refresh(); - SetTimer(_hwnd, 0, 200, NULL); + if (_HasShellHook) + RegisterShellHookWindow(_hwnd); + else + SetTimer(_hwnd, 0, 200, NULL); return 0; } 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) { case WM_SIZE: 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; 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; diff --git a/reactos/subsys/system/explorer/taskbar/taskbar.h b/reactos/subsys/system/explorer/taskbar/taskbar.h index bc1d4e0bb03..8a1503371c8 100644 --- a/reactos/subsys/system/explorer/taskbar/taskbar.h +++ b/reactos/subsys/system/explorer/taskbar/taskbar.h @@ -85,6 +85,7 @@ protected: int _next_id; WindowHandle _last_foreground_wnd; int _last_btn_width; + BOOL _HasShellHook; LRESULT Init(LPCREATESTRUCT pcs); LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam); diff --git a/reactos/w32api/include/winuser.h b/reactos/w32api/include/winuser.h index 8b620ca19a5..11aa8218899 100644 --- a/reactos/w32api/include/winuser.h +++ b/reactos/w32api/include/winuser.h @@ -3708,6 +3708,7 @@ BOOL WINAPI RegisterLogonProcess(DWORD,BOOL); #if (_WIN32_WINNT >= 0x0501) BOOL WINAPI RegisterRawInputDevices(PCRAWINPUTDEVICE,UINT,UINT); #endif +BOOL WINAPI RegisterShellHookWindow(HWND); UINT WINAPI RegisterWindowMessageA(LPCSTR); UINT WINAPI RegisterWindowMessageW(LPCWSTR); BOOL WINAPI ReleaseCapture(void);