cleanup of latest RegisterShellHookWindow() changes
Modified: trunk/reactos/subsys/system/explorer/taskbar/taskbar.cpp
Modified: trunk/reactos/subsys/system/explorer/taskbar/taskbar.h
_____
Modified: trunk/reactos/subsys/system/explorer/taskbar/taskbar.cpp
--- trunk/reactos/subsys/system/explorer/taskbar/taskbar.cpp
2005-03-18 19:36:36 UTC (rev 14181)
+++ trunk/reactos/subsys/system/explorer/taskbar/taskbar.cpp
2005-03-18 20:34:01 UTC (rev 14182)
@@ -53,29 +53,20 @@
TaskBar::TaskBar(HWND hwnd)
- : super(hwnd)
+ : super(hwnd),
+ WM_SHELLHOOK(RegisterWindowMessage(TEXT("SHELLHOOK")))
{
- 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()
{
- if (!_HasShellHook)
- KillTimer(_hwnd, 0);
+ DynamicFct<BOOL (WINAPI*)(HWND hwnd)>
DeregisterShellHookWindow(TEXT("user32"),
"DeregisterShellHookWindow");
- //DeinstallShellHook();
+ if (DeregisterShellHookWindow)
+ (*DeregisterShellHookWindow)(_hwnd);
+ else
+ KillTimer(_hwnd, 0);
}
HWND TaskBar::Create(HWND hwndParent)
@@ -108,26 +99,23 @@
_next_id = IDC_FIRST_APP;
- //InstallShellHook(_hwnd, PM_SHELLHOOK_NOTIFY);
+ DynamicFct<BOOL (WINAPI*)(HWND hwnd)>
RegisterShellHookWindow(TEXT("user32"), "RegisterShellHookWindow");
- Refresh();
-
- if (_HasShellHook)
- RegisterShellHookWindow(_hwnd);
- else
+ if (RegisterShellHookWindow) {
+ LOG(TEXT("Using shell hooks for notification of shell
events."));
+ (*RegisterShellHookWindow)(_hwnd);
+ } else {
+ LOG(TEXT("Shell hooks not available."));
SetTimer(_hwnd, 0, 200, NULL);
+ }
+ Refresh();
+
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);
@@ -167,9 +155,10 @@
return (LRESULT)(HWND)_last_foreground_wnd;
default: def:
- if (nmsg == RegisterWindowMessage(TEXT("SHELLHOOK"))) {
+ if (nmsg == WM_SHELLHOOK) {
LOG(FmtString(TEXT("SHELLHOOK %x"), wparam));
- switch (wparam) {
+
+ switch(wparam) {
case HSHELL_WINDOWCREATED:
case HSHELL_WINDOWDESTROYED:
case HSHELL_WINDOWACTIVATED:
_____
Modified: trunk/reactos/subsys/system/explorer/taskbar/taskbar.h
--- trunk/reactos/subsys/system/explorer/taskbar/taskbar.h
2005-03-18 19:36:36 UTC (rev 14181)
+++ trunk/reactos/subsys/system/explorer/taskbar/taskbar.h
2005-03-18 20:34:01 UTC (rev 14182)
@@ -84,9 +84,10 @@
TaskBarMap _map;
int _next_id;
WindowHandle _last_foreground_wnd;
- int _last_btn_width;
- BOOL _HasShellHook;
+ int _last_btn_width;
+ const UINT WM_SHELLHOOK;
+
LRESULT Init(LPCREATESTRUCT pcs);
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
int Command(int id, int code);
Show replies by date