The new example works well
How about a dock relative option?
Cheers.
Dock - Attach a window to another
Re: Dock - Attach a window to another
you mean like this ?Helgef wrote:dock relative option?
AutoHotkey & AutoHotkey_H v1.1.22.07
Re: Dock - Attach a window to another
That is nice but not what I meant.
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
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
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)
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.
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
-
- Posts: 1
- Joined: 16 Aug 2019, 12:49
Re: Dock - Attach a window to another
@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!
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
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.
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
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
Donations
Discord
All code is done on a 64 bit Windows 10 PC Running AutoHotkey x32
Re: Dock - Attach a window to another
so ,where is the code ..?Soft wrote: ↑09 May 2017, 10:18update 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
Re: Dock - Attach a window to another
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: No registered users and 172 guests