Dock - Attach a window to another

Post your working scripts, libraries and tools for AHK v1.1 and older
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Dock - Attach a window to another

09 May 2017, 10:56

The new example works well :thumbup:
How about a dock relative option? :P

Cheers.
User avatar
Soft
Posts: 174
Joined: 07 Jan 2015, 13:18
Location: Seoul
Contact:

Re: Dock - Attach a window to another

10 May 2017, 04:30

Helgef wrote:dock relative option?
you mean like this ?
AutoHotkey & AutoHotkey_H v1.1.22.07
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Dock - Attach a window to another

10 May 2017, 04:59

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
ahk7
Posts: 575
Joined: 06 Nov 2013, 16:35

Re: Dock - Attach a window to another

16 Dec 2018, 11:16

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.
armyfrog123
Posts: 1
Joined: 16 Aug 2019, 12:49

Re: Dock - Attach a window to another

16 Aug 2019, 12:54

@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!
gave92
Posts: 7
Joined: 04 Mar 2020, 08:38
Contact:

Re: Dock - Attach a window to another

10 Mar 2020, 03:44

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.
User avatar
maestrith
Posts: 825
Joined: 16 Oct 2013, 13:52

Re: Dock - Attach a window to another

14 Mar 2020, 08:06

Impressive!
John H Wilson III 05/29/51 - 03/01/2020. You will be missed.AHK Studio OSDGUI Creator
Donations
Discord
All code is done on a 64 bit Windows 10 PC Running AutoHotkey x32
bluesky
Posts: 11
Joined: 24 Dec 2020, 20:15

Re: Dock - Attach a window to another

26 Dec 2020, 08:14

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 ..? :?:
gregster
Posts: 9087
Joined: 30 Sep 2013, 06:48

Re: Dock - Attach a window to another

26 Dec 2020, 08:20

bluesky wrote:
26 Dec 2020, 08:14
so ,where is the code ..? :?:
See first post of this topic.
bluesky
Posts: 11
Joined: 24 Dec 2020, 20:15

Re: Dock - Attach a window to another

03 Jan 2021, 20:20

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				
			}



Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: ftlsxp, kaka2 and 126 guests