Page 2 of 2

Re: Dock - Attach a window to another

Posted: 09 May 2017, 10:56
by Helgef
The new example works well :thumbup:
How about a dock relative option? :P

Cheers.

Re: Dock - Attach a window to another

Posted: 10 May 2017, 04:30
by Soft
Helgef wrote:dock relative option?
you mean like this ?

Re: Dock - Attach a window to another

Posted: 10 May 2017, 04:59
by Helgef
That is nice but not what I meant. :thumbup:
I meant that the client moves by the same amount as the host, but doesn't snap to the border of the host. The windows keeps their realtive distance. I think then client should be (optional) movable to new realtive posistion.
Cheers

Re: Dock - Attach a window to another

Posted: 16 Dec 2018, 11:16
by ahk7
Just messing about a bit - An attempt at adding a "Relative" option here https://gist.github.com/hi5/f20d6ffce5f ... af580967db

Usage:
Instance.Position("Relative 25 5") coordinates from top left corner so this will place something in the title bar of the host window.

Example - clock in title bar of notepad window (esc to close script)

Code: Select all

; example dock with Relative position
#NoEnv
#SingleInstance, force
SetTitleMatchMode, 2

FormatTime, TimeString, , HH:mm:ss 
Run, notepad.exe
sleep 100
WinGet, HostHwnd, ID, ahk_exe notepad.exe

; clock gui
Gui, +hwndClienthwnd +ToolWindow +AlwaysOnTop -SysMenu +E0x08000000
Gui, -Caption ; use this to remove the tooltip top!
Gui, Color, CCCCCC
Gui, Add, Picture, x3 y0 icon44 w16, shell32.dll
Gui, Font, cFFFFFF s6 wbold, terminal
Gui, Add, Text, vTxtCurrentTime  xp+20 y2, %TimeString% 

; Instance := new Dock(Host hwnd, Client hwnd, [Callback], [CloseCallback])
Instance := new Dock(Hosthwnd, Clienthwnd)
Instance.CloseCallback := Func("CloseCallback")

Gui, Show, AutoSize NoActivate h18 w240
WinSet, TransColor, CCCCCC 255, ahk_class AutoHotkeyGUI
Instance.Position("Relative 25 5")
SetTimer, AdjustTime, 500
Return

CloseCallback(self)
{
	WinKill, % "ahk_id " self.hwnd.Client
	ExitApp
}


Esc::
GuiClose:
Gui, Destroy
ExitApp

AdjustTime:
FormatTime, TimeString, , HH:mm:ss
GuiControl, , TxtCurrentTime, %TimeString%
return

#include dock.ahk
Not entirely perfect yet because when I minimize the window and expand it again the clock is "gone", when you alt-tab a few windows the clock will be there. Not sure if its DOCK or the Gui code for the clock that is the cause. (tested Windows 8, 64bit) - Sometimes the clock stays visible above other windows as well.

Re: Dock - Attach a window to another

Posted: 16 Aug 2019, 12:54
by armyfrog123
@Soft

Hi Soft, this is a great piece of code for a beginner like me. Where do you declare the Host window? I know a little bit of java, but the syntax is different enough it's throwing me for a loop.

Thanks a ton!

Re: Dock - Attach a window to another

Posted: 10 Mar 2020, 03:44
by gave92
Hello thanks for your great work.
I've been using this class for changing tha titlebar/border color of windows:
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=73197
A tiny bug has been reported to me: the Dock class does not handle the Hide window event so if you hide a window with WinHide the attached window will not be hidden.
I've fixed this in a modified Dock.ahk you can find in the above link (basically I added listening to EVENT_OBJECT_HIDE and EVENT_OBJECT_SHOW window events)
Note that the above class includes other edits to fit my script scenario.

Re: Dock - Attach a window to another

Posted: 14 Mar 2020, 08:06
by maestrith
Impressive!

Re: Dock - Attach a window to another

Posted: 26 Dec 2020, 08:14
by bluesky
Soft wrote:
09 May 2017, 10:18
update 0.2.2
  • -It is now possible to dock more than one window (still WIP, its code and style are provisional)
  • -changed some class properties's name for future consistency
  • -Now Host (formerly main window) and Client window(formerly attached window) dock each other
  • -several changes... see code and example to check out
so ,where is the code ..? :?:

Re: Dock - Attach a window to another

Posted: 26 Dec 2020, 08:20
by gregster
bluesky wrote:
26 Dec 2020, 08:14
so ,where is the code ..? :?:
See first post of this topic.

Re: Dock - Attach a window to another

Posted: 03 Jan 2021, 20:20
by bluesky
gregster wrote:
26 Dec 2020, 08:20
bluesky wrote:
26 Dec 2020, 08:14
so ,where is the code ..? :?:
See first post of this topic.
thanks,My network problem caused unable to view,I use a proxy to solved.
Another question is how to implement the embedded dock window, the client window is always displayed in and above the host window,I am not sure how to set top is better ...
and imply a really embedded mode.... such as hide taskbar icon,like MDI window ...

some demo code like this:

Code: Select all

	EVENT_OBJECT_LOCATIONCHANGE(self, via)
		{
			Host := this.WinGetPos(self.hwnd.Host)
			Client := this.WinGetPos(self.hwnd.Client)

			If InStr(self.pos, "Embedded")
			{
				If (via = "host")
				{
					Return this.MoveWindow(self.hwnd.Client 	;hwnd
								, Host.x + Host.w/2		;x
								, Host.y 	;y
								, Client.w	  	;width
								, Client.h) 		;height
				}

				If (via = "client")
				{
					Return this.MoveWindow(self.hwnd.Host	   	;hwnd
								, Client.x-Host.w/2	  	;x
								, Client.y   ;y
								, Host.w		;width
								, Host.h)	   	;height
				}
				WinSet, AlwaysOnTop, On, % "ahk_id " . self.hwnd.Client				
			}