docking toolbar fixes from Thomas. 1st attempt at always active floating toolbars

svn path=/trunk/; revision=21377
This commit is contained in:
Ged Murphy 2006-03-24 20:59:38 +00:00
parent e3342f0b3e
commit a6e679a8b3
3 changed files with 114 additions and 7 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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);