From a6e679a8b3ccf5f6b9031a640de1d875b6922689 Mon Sep 17 00:00:00 2001 From: Ged Murphy Date: Fri, 24 Mar 2006 20:59:38 +0000 Subject: [PATCH] docking toolbar fixes from Thomas. 1st attempt at always active floating toolbars svn path=/trunk/; revision=21377 --- reactos/base/applications/imagesoft/mainwnd.c | 20 +++- reactos/base/applications/imagesoft/precomp.h | 7 ++ .../base/applications/imagesoft/tooldock.c | 94 ++++++++++++++++++- 3 files changed, 114 insertions(+), 7 deletions(-) diff --git a/reactos/base/applications/imagesoft/mainwnd.c b/reactos/base/applications/imagesoft/mainwnd.c index bcbe093ab29..c42fa06f86e 100644 --- a/reactos/base/applications/imagesoft/mainwnd.c +++ b/reactos/base/applications/imagesoft/mainwnd.c @@ -978,11 +978,28 @@ MainWndProc(HWND hwnd, break; } + case WM_ENABLE: + { + TbdHandleEnabling(&Info->ToolDocks, + hwnd, + (BOOL)wParam); + goto HandleDefaultMessage; + } + + case WM_NCACTIVATE: + { + TbdHandleActivation(&Info->ToolDocks, + hwnd, + &wParam, + &lParam); + goto HandleDefaultMessage; + } + case WM_ACTIVATEAPP: { //TbdShowFloatingToolbars(&Info->ToolDocks, // (BOOL)wParam); - break; + goto HandleDefaultMessage; } case WM_CREATE: @@ -1001,7 +1018,6 @@ MainWndProc(HWND hwnd, /* Show the window */ ShowWindow(hwnd, Info->nCmdShow); - /* get the windows position */ GetWindowRect(hwnd, &wndOldPos); diff --git a/reactos/base/applications/imagesoft/precomp.h b/reactos/base/applications/imagesoft/precomp.h index ec2b99c3356..8cda9be8470 100644 --- a/reactos/base/applications/imagesoft/precomp.h +++ b/reactos/base/applications/imagesoft/precomp.h @@ -254,6 +254,13 @@ BOOL TbdAddToolbar(PTOOLBAR_DOCKS TbDocks, BOOL TbdHandleNotifications(PTOOLBAR_DOCKS TbDocks, LPNMHDR pnmh, LRESULT *Result); +VOID TbdHandleEnabling(PTOOLBAR_DOCKS TbDocks, + HWND hWnd, + BOOL Enable); +VOID TbdHandleActivation(PTOOLBAR_DOCKS TbDocks, + HWND hWnd, + WPARAM *wParam, + LPARAM *lParam); VOID TbdShowFloatingToolbars(PTOOLBAR_DOCKS TbDocks, BOOL Show); BOOL TbdInitImpl(VOID); diff --git a/reactos/base/applications/imagesoft/tooldock.c b/reactos/base/applications/imagesoft/tooldock.c index 798e1fba925..6531cd95948 100644 --- a/reactos/base/applications/imagesoft/tooldock.c +++ b/reactos/base/applications/imagesoft/tooldock.c @@ -611,7 +611,9 @@ TbdAddToolbar(PTOOLBAR_DOCKS TbDocks, return FALSE; } -#define GWLP_DOCKITEM 0 +#define GWLP_TBDOCKS 0 +#define GWLP_DOCKITEM (GWLP_TBDOCKS + sizeof(PTOOLBAR_DOCKS)) +#define TD_EXTRA_BYTES (GWLP_DOCKITEM + sizeof(PDOCKBAR_ITEM)) static LRESULT CALLBACK ToolDockWndProc(HWND hwnd, @@ -625,9 +627,10 @@ ToolDockWndProc(HWND hwnd, /* Get the window context */ TbDocks = (PTOOLBAR_DOCKS)GetWindowLongPtr(hwnd, - GWLP_USERDATA); + GWLP_TBDOCKS); Item = (PDOCKBAR_ITEM)GetWindowLongPtr(hwnd, GWLP_DOCKITEM); + if ((TbDocks == NULL || Item == NULL) && uMsg != WM_CREATE) { goto HandleDefaultMessage; @@ -635,6 +638,15 @@ ToolDockWndProc(HWND hwnd, switch (uMsg) { + case WM_NCACTIVATE: + { + TbdHandleActivation(TbDocks, + hwnd, + &wParam, + &lParam); + goto HandleDefaultMessage; + } + case WM_CREATE: { TbDocks = ((PTOOLDOCKWND_INIT)(((LPCREATESTRUCT)lParam)->lpCreateParams))->TbDocks; @@ -642,11 +654,13 @@ ToolDockWndProc(HWND hwnd, Item->hWndTool = hwnd; SetWindowLongPtr(hwnd, - GWLP_USERDATA, + GWLP_TBDOCKS, (LONG_PTR)TbDocks); SetWindowLongPtr(hwnd, GWLP_DOCKITEM, - (LONG_PTR)GWLP_DOCKITEM); + (LONG_PTR)Item); + + Ret = TRUE; break; } @@ -932,6 +946,76 @@ MoveFailed: return Ret; } +VOID +TbdHandleEnabling(PTOOLBAR_DOCKS TbDocks, + HWND hWnd, + BOOL Enable) +{ + PDOCKBAR_ITEM Item; + + Item = TbDocks->Items; + while (Item != NULL) + { + if (Item->hWndTool != NULL && + Item->hWndTool != hWnd) + { + EnableWindow(Item->hWndTool, + Enable); + } + Item = Item->Next; + } +} + +VOID +TbdHandleActivation(PTOOLBAR_DOCKS TbDocks, + HWND hWnd, + WPARAM *wParam, + LPARAM *lParam) +{ + BOOL SynchronizeSiblings = TRUE; + BOOL KeepActive = *(BOOL*)wParam; + HWND hWndActivate = *(HWND*)lParam; + PDOCKBAR_ITEM Item; +DbgPrint("-- 0x%p --\n", hWnd); + Item = TbDocks->Items; + while (Item != NULL) + { + if (Item->hWndTool != NULL && + Item->hWndTool == hWndActivate) + {DbgPrint("Activate toolbars (0x%p)\n", hWndActivate); + KeepActive = TRUE; + SynchronizeSiblings = FALSE; + break; + } + Item = Item->Next; + } + + if (hWndActivate != (HWND)-1) + { + if (SynchronizeSiblings) + { + Item = TbDocks->Items; + while (Item != NULL) + { + if (Item->hWndTool != NULL && + Item->hWndTool != hWnd && + Item->hWndTool != hWndActivate) + {DbgPrint("WM_NCACTIVE %p (wnd %p)\n", KeepActive, Item->hWndTool); + SendMessage(Item->hWndTool, + WM_NCACTIVATE, + (WPARAM)KeepActive, + (LPARAM)-1); + } + Item = Item->Next; + } + } + } + else + *lParam = 0; + + *wParam = (WPARAM)KeepActive; +} + VOID TbdShowFloatingToolbars(PTOOLBAR_DOCKS TbDocks, BOOL Show) @@ -1014,7 +1098,7 @@ TbdInitImpl(VOID) wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = ToolDockWndProc; - wc.cbWndExtra = sizeof(PDOCKBAR_ITEM); + wc.cbWndExtra = TD_EXTRA_BYTES; wc.hInstance = hInstance; wc.hCursor = LoadCursor(NULL, IDC_ARROW);