Dock

Dock desired top level windows (dock clients) to any top level window (dock host)

 

Using dock module you can glue your or third-party windows to any top level window.  Docked windows in module terminology are called Clients and the window that keeps their position relative to itself is called Host.  Once Clients are connected to the Host, this group of windows will behave like single window - moving, sizing, focusing, hiding and other OS events will be handled by the module so that the “composite window” behaves like the single window.

Module uses system hook to monitor windows changes, so it’s idle when it is not aranging windows.

Summary
Dock desired top level windows (dock clients) to any top level window (dock host)
Instantiate dock of given client upon host.
Uninitialize dock module.
Toggles the dock module ON or OFF.
This section contains some common docking setups.

Dock

Dock(pClientID,  
pDockDef = "",
reset = 0)

Instantiate dock of given client upon host.  Multiple clients per one host are supported.

Parameters

pClientIdHWND of the Client GUI.  Dock is created or updated (if already exists) for that hwnd.  If “+” is the first char of pClientId, Dock will first show the window if it is hidden (for smoother initialisation)
pDockDefDock definition, see bellow.  To remove dock client pass “-”.  If you pass empty string, client will be docked to the host according to its current position relative to the host.
resetinternal parameter, do not use.

Globals

Dock_HostIDSets docking host
Dock_OnHostDeathSets label that will be called when host dies.  Afterwards, module will disable itself using Dock_Toggle(false).

Dock definition

Dock definition is string containing 10 numbers that describe Client positon relative to the Host.  The big number of parameters allows fine tuning of Client’s postion and basicly every setup is possible.  Parameters are grouped in 4 classes - first 3 influence X coordinate of the client, next 3 Y coordinate, next 2 Client’s width and final 2 Client’s height:

                  xhw,xw,xd,  yhh,yh,yd [, whw,wd,  hhh,hd]
  X Y W H
  • The X coordinate of the top, left corner of the client window is computed as HostX + xhw*HostWidth + xw*ClientWidth + xd, with the parameters xhw, xw and xd
  • The Y coordinate of the top, left corner of the client window is computed as HostY + yhh*HostHeight + yh*ClientHeight + yd, with the parameters yhh, yh and yd
  • The width W of the client window is computed as whw*HostWidth + wd, with the parameters whw and wd.  Skip to let the client have its own width (or set to 0,0)
  • The height H of the client window is computed as hhh*HostHeight + hd, with the parameters hhh and hd.  Skip to let the client have its own height (or set to 0,0)

Returns

”OK” or “Err” with text describing last succesiful or failed action.

Remarks

You must set DetectHiddenWindows if Host is practicing hiding.  Otherwise, Dock will treat Host hiding as death.  All clients will be hidden once host is terminated or it becomes hidden itself.

Use SetBatchLines, -1 with dock module for fluid client movement.  You will experience delay in clients moving otherwise.  However, if CPU usage is very high, you might experience a delay in client movement anyway.

If you are using Gui, Show command imediately before registering client, make sure you specify NoActivate flag.

Currently its not supported to set Client window on top Host window.  AlwaysOnTop (or TopMost) flag will not influence behavior of the module so avoid setups in which client is entirely covered by the Host.

Example

Dock(Client1ID, "0,-1,-10, 0,0,0, 0,63, 1,0")      ;top left, host height
Dock(Client2ID, "0,0,0, 0,-1,-5, 1,0,0,30") ;top above, host width

Dock_Shutdown

Dock_Shutdown()

Uninitialize dock module.  This will clear all clients and internal data and unregister hooks.  Dock_OnHostDeath, Dock_HostId are kept on user values.

Dock_Toggle

Dock_Toggle(enable = "")

Toggles the dock module ON or OFF.

Parameters

enableSet to true to set the dock ON, set to FALSE to turn it OFF.  Skip to toggle.

Remarks

Use Dock_Toggle(false) to suspend the dock module (to unregister hook), leaving its internal data in place.  This is different from Dock_Shutdown as latest removes module completely from memory and unregisters its clients.

You can also use this function to temporary disable module when you don’t want dock update routine to interrupt your time critical sections.

Presets

This section contains some common docking setups.  You can just copy/paste dock definition strings in your script.

0,-1,0, 0,0,0top left, own size
0,-1,10, 0,0,0top left, own size, 10px padding
0,-1,0, 0,0,0, 0,0, 1,0top left, use host’s height, keep own width
0,-1,20, 0,0,0, 0,50, 1,0top left, use host’s height, set width to 50 and padding to 20px
0,-1,0, .5,-.5,0middle left, keep own size
0,-1,0, 1,-1,0, 0,20, 0,20bottom left, fixed width & height to 20px
0,-1,0, 1,-1,0, 0,0, .5,0bottom left, keep height half of the Host’s height, keep own width
1,-1,0, 1,0,0, .25,0 .25,0bottom right, width and height 1/5 of the Host
0,0,0, 1,0,0, 1,0, 0,100below the host, use host’s width, height = 100
0,0,0, 0,-1,-5, 1,0above the host, use host’s width, keep own height, 5px padding
.5,-.5,0, 0,-1,0, 0,200, 0,30center above the host, width=200, height=30
.5,-.5,0, 1,0,0, 0.3,0, 0,30center bellow the host, use 1/3 Host’s width, height=30
1,0,0, 0,0,0top right, own size
1,0,0, 0,0,0, 0,40, 1,0top right, use host’s height, width = 40
1,0,0, .5,-.5,0middle right, keep own size

About

Dock(pClientID,  
pDockDef = "",
reset = 0)
Instantiate dock of given client upon host.
Dock_Shutdown()
Uninitialize dock module.
Dock_Toggle(enable = "")
Toggles the dock module ON or OFF.