From 03a5f16ed97666d0ec75febc9e88923713baad21 Mon Sep 17 00:00:00 2001 From: Martin Fuchs Date: Sun, 27 Mar 2005 19:57:26 +0000 Subject: [PATCH] - make Shell Hook Messages really work in Windows - comments for SHELL32's RegisterShellHook() svn path=/trunk/; revision=14354 --- .../system/explorer/desktop/desktop.cpp | 2 +- .../system/explorer/shell/mainframe.cpp | 1 - .../system/explorer/taskbar/startmenu.cpp | 1 - .../system/explorer/taskbar/taskbar.cpp | 49 ++++++++++++++++++- .../subsys/system/explorer/taskbar/taskbar.h | 1 + .../system/explorer/taskbar/traynotify.cpp | 2 +- .../system/explorer/utility/utility.cpp | 2 +- .../subsys/system/explorer/utility/utility.h | 2 + .../subsys/system/explorer/utility/window.cpp | 2 +- .../subsys/system/explorer/utility/window.h | 2 + 10 files changed, 56 insertions(+), 8 deletions(-) diff --git a/reactos/subsys/system/explorer/desktop/desktop.cpp b/reactos/subsys/system/explorer/desktop/desktop.cpp index 55e90e1f7d3..12f053f46e5 100644 --- a/reactos/subsys/system/explorer/desktop/desktop.cpp +++ b/reactos/subsys/system/explorer/desktop/desktop.cpp @@ -436,7 +436,7 @@ LRESULT DesktopWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) case WM_DESTROY: ///@todo use IShellBrowser::GetViewStateStream() and _pShellView->SaveViewState() to store view state - + if (SetShellWindow) SetShellWindow(0); break; diff --git a/reactos/subsys/system/explorer/shell/mainframe.cpp b/reactos/subsys/system/explorer/shell/mainframe.cpp index 10699aa7b6d..1efd2d2a087 100644 --- a/reactos/subsys/system/explorer/shell/mainframe.cpp +++ b/reactos/subsys/system/explorer/shell/mainframe.cpp @@ -736,7 +736,6 @@ MDIMainFrame::MDIMainFrame(HWND hwnd) extraBtns.idCommand = ID_WEB_WINDOW; SendMessage(_hextrabar, TB_INSERTBUTTON, INT_MAX, (LPARAM)&extraBtns); -#define W_VER_NT 0 if ((HIWORD(GetVersion())>>14) == W_VER_NT) { // insert NT object namespace button extraBtns.iString = SendMessage(_hextrabar, TB_ADDSTRING, 0, (LPARAM)TEXT("NT Obj\0")); diff --git a/reactos/subsys/system/explorer/taskbar/startmenu.cpp b/reactos/subsys/system/explorer/taskbar/startmenu.cpp index ec13b87a82a..6868ad18596 100644 --- a/reactos/subsys/system/explorer/taskbar/startmenu.cpp +++ b/reactos/subsys/system/explorer/taskbar/startmenu.cpp @@ -1952,7 +1952,6 @@ void StartMenuHandler::ShowLaunchDialog(HWND hwndOwner) // Show "Run..." dialog if (RunFileDlg) { #ifndef _ROS_ /* FIXME: our shell32 always expects Ansi strings */ -#define W_VER_NT 0 if ((HIWORD(GetVersion())>>14) == W_VER_NT) { WCHAR wTitle[40], wText[256]; diff --git a/reactos/subsys/system/explorer/taskbar/taskbar.cpp b/reactos/subsys/system/explorer/taskbar/taskbar.cpp index aa3b5224697..cb64e9bd84f 100644 --- a/reactos/subsys/system/explorer/taskbar/taskbar.cpp +++ b/reactos/subsys/system/explorer/taskbar/taskbar.cpp @@ -36,6 +36,16 @@ DynamicFct g_SetTaskmanWindow(TEXT("user32"), "SetTas DynamicFct g_RegisterShellHookWindow(TEXT("user32"), "RegisterShellHookWindow"); DynamicFct g_DeregisterShellHookWindow(TEXT("user32"), "DeregisterShellHookWindow"); +/* +DynamicFct g_RegisterShellHook(TEXT("shell32"), (LPCSTR)0xb5); + + // constants for RegisterShellHook() +#define RSH_UNREGISTER 0 +#define RSH_REGISTER 1 +#define RSH_REGISTER_PROGMAN 2 +#define RSH_REGISTER_TASKMAN 3 +*/ + TaskBarEntry::TaskBarEntry() { @@ -59,13 +69,30 @@ TaskBarMap::~TaskBarMap() TaskBar::TaskBar(HWND hwnd) : super(hwnd), - WM_SHELLHOOK(RegisterWindowMessage(TEXT("SHELLHOOK"))) + WM_SHELLHOOK(RegisterWindowMessage(WINMSG_SHELLHOOK)) { _last_btn_width = 0; + + _mmMetrics_org.cbSize = sizeof(MINIMIZEDMETRICS); + + SystemParametersInfo(SPI_GETMINIMIZEDMETRICS, sizeof(_mmMetrics_org), &_mmMetrics_org, 0); + + // configure the window manager to hide windows when they are minimized + // This is neccessary to enable shell hook messages. + if (!(_mmMetrics_org.iArrange & ARW_HIDE)) { + MINIMIZEDMETRICS _mmMetrics_new = _mmMetrics_org; + + _mmMetrics_new.iArrange |= ARW_HIDE; + + SystemParametersInfo(SPI_SETMINIMIZEDMETRICS, sizeof(_mmMetrics_new), &_mmMetrics_new, 0); + } } TaskBar::~TaskBar() { +// if (g_RegisterShellHook) +// (*g_RegisterShellHook)(_hwnd, RSH_UNREGISTER); + if (g_DeregisterShellHookWindow) (*g_DeregisterShellHookWindow)(_hwnd); else @@ -73,6 +100,8 @@ TaskBar::~TaskBar() if (g_SetTaskmanWindow) (*g_SetTaskmanWindow)(0); + + SystemParametersInfo(SPI_GETMINIMIZEDMETRICS, sizeof(_mmMetrics_org), &_mmMetrics_org, 0); } HWND TaskBar::Create(HWND hwndParent) @@ -105,7 +134,7 @@ LRESULT TaskBar::Init(LPCREATESTRUCT pcs) _next_id = IDC_FIRST_APP; - // register ourselved as task manager window to make the following call to RegisterShellHookWindow working + // register the taskbar window as task manager window to make the following call to RegisterShellHookWindow working if (g_SetTaskmanWindow) (*g_SetTaskmanWindow)(_hwnd); @@ -118,6 +147,16 @@ LRESULT TaskBar::Init(LPCREATESTRUCT pcs) SetTimer(_hwnd, 0, 200, NULL); } +/* Alternatively we could use the RegisterShellHook() function in SHELL32, but this is not yet implemented in the WINE code. + if (g_RegisterShellHook) { + (*g_RegisterShellHook)(0, RSH_REGISTER); + + if ((HIWORD(GetVersion())>>14) == W_VER_NT) + (*g_RegisterShellHook)(_hwnd, RSH_REGISTER_TASKMAN); + else + (*g_RegisterShellHook)(_hwnd, RSH_REGISTER); + } +*/ Refresh(); return 0; @@ -156,6 +195,10 @@ LRESULT TaskBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) case HSHELL_WINDOWDESTROYED: case HSHELL_WINDOWACTIVATED: case HSHELL_REDRAW: +#ifdef HSHELL_FLASH + case HSHELL_FLASH: + case HSHELL_RUDEAPPACTIVATED: +#endif Refresh(); break; } @@ -409,6 +452,7 @@ BOOL CALLBACK TaskBar::EnumWndProc(HWND hwnd, LPARAM lparam) entry._fsState = btn.fsState; +#ifdef _ROS_ // now handled by activating the ARW_HIDE flag with SystemParametersInfo(SPI_SETMINIMIZEDMETRICS) // move minimized windows out of sight if (IsIconic(hwnd)) { RECT rect; @@ -418,6 +462,7 @@ BOOL CALLBACK TaskBar::EnumWndProc(HWND hwnd, LPARAM lparam) if (rect.bottom > 0) SetWindowPos(hwnd, 0, -32000, -32000, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE); } +#endif } return TRUE; diff --git a/reactos/subsys/system/explorer/taskbar/taskbar.h b/reactos/subsys/system/explorer/taskbar/taskbar.h index b2a11740475..76512eed6d9 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; + MINIMIZEDMETRICS _mmMetrics_org; const UINT WM_SHELLHOOK; diff --git a/reactos/subsys/system/explorer/taskbar/traynotify.cpp b/reactos/subsys/system/explorer/taskbar/traynotify.cpp index 072e387318c..8cca2f36525 100644 --- a/reactos/subsys/system/explorer/taskbar/traynotify.cpp +++ b/reactos/subsys/system/explorer/taskbar/traynotify.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2003, 2004 Martin Fuchs + * Copyright 2003, 2004, 2005 Martin Fuchs * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/reactos/subsys/system/explorer/utility/utility.cpp b/reactos/subsys/system/explorer/utility/utility.cpp index 5e8f63d17e4..4e95db4a004 100644 --- a/reactos/subsys/system/explorer/utility/utility.cpp +++ b/reactos/subsys/system/explorer/utility/utility.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2003, 2004 Martin Fuchs + * Copyright 2003, 2004, 2005 Martin Fuchs * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/reactos/subsys/system/explorer/utility/utility.h b/reactos/subsys/system/explorer/utility/utility.h index c5de7091467..8a0e5c30e1e 100644 --- a/reactos/subsys/system/explorer/utility/utility.h +++ b/reactos/subsys/system/explorer/utility/utility.h @@ -59,6 +59,8 @@ #define _MAX_PATH 260 #endif +#define W_VER_NT 0 // constant for HIWORD(GetVersion())>>14 + #ifdef __cplusplus extern "C" { diff --git a/reactos/subsys/system/explorer/utility/window.cpp b/reactos/subsys/system/explorer/utility/window.cpp index bbeba49d988..f7cf1ae237e 100644 --- a/reactos/subsys/system/explorer/utility/window.cpp +++ b/reactos/subsys/system/explorer/utility/window.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2003, 2004 Martin Fuchs + * Copyright 2003, 2004, 2005 Martin Fuchs * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/reactos/subsys/system/explorer/utility/window.h b/reactos/subsys/system/explorer/utility/window.h index 4f716085ca0..1e60a738250 100644 --- a/reactos/subsys/system/explorer/utility/window.h +++ b/reactos/subsys/system/explorer/utility/window.h @@ -984,6 +984,8 @@ enum {TRAYBUTTON_LEFT=0, TRAYBUTTON_RIGHT, TRAYBUTTON_MIDDLE}; #define WINMSG_TASKBARCREATED TEXT("TaskbarCreated") +#define WINMSG_SHELLHOOK TEXT("SHELLHOOK") + struct TrayIcon {