Move GUIs together

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
blueblue
Posts: 3
Joined: 20 Jul 2017, 18:16

Move GUIs together

20 Jul 2017, 18:32

Hi, I have two GUIs that I would like to move simultaneously as one. I've tried the DLL call for SetParent which I can't get to work. How do I accomplish this?

Code: Select all


#SingleInstance force

CustomColor = 203864

Gui 1: New
Gui +LastFound +AlwaysOnTop -Caption +E0x20  ; +ToolWindow avoids a taskbar button and an alt-tab menu item.
Gui, 1: Color, %CustomColor%
Gui, 1: Font, s18 

dwidth := "520"


Gui, 1: Add, Text, vMyText gmove1 cWhite BackgroundTrans, someverycoolstuffrighthere 
Gui, 1: +HwndMyGuiHwnd
Gui, 1: Show, x%dwidth% y50 NoActivate  



gui, 2: new
Gui +LastFound +AlwaysOnTop -Caption +E0x20 +ToolWindow
Gui, 2: Add, Text, H50 R2 vMyText2 cRed, someothernolesscoolstuffhere

  Gui, 2: +LastFound 
 DllCall("SetParent", "uint", WinExist(), "uint", %MyGuiHwnd%) ; success = handle to previous parent, failure =null


Gui, 2: Show, x700 y80 NoActivate

return


move1:
PostMessage, 0xA1, 2,,, A

return
The blue one moves without the other one.
User avatar
noname
Posts: 515
Joined: 19 Nov 2013, 09:15

Re: Move GUIs together

21 Jul 2017, 08:10

Simple example linking two Gui's :

Code: Select all

Gui, 1: +hwndhwnd1 +ToolWindow
Gui, 1: show , w250 h100 x100 y100 ,move one


Gui, 2: +hwndhwnd2  +ToolWindow
Gui, 2: Show, w250 h100 x400 y100 ,move two

OnMessage(0x201,"WM_LBUTTONDOWN")
OnMessage(0x03, "WM_MOVE")
return



WM_LBUTTONDOWN(wParam,lParam,msg,hwnd){
	PostMessage, 0xA1, 2
}

WM_Move(wP,lP,msg)
{
global hwnd2 ,hwnd1
   WinGetPos, x1,y1,w1,h1, ahk_id %hwnd1%
   WinGetPos, x2,y2,w2,h2, ahk_id %hwnd2%
if (WinExist("A") =hwnd1)
winmove,ahk_id %hwnd2%,,x1+w1,y1
else if (WinExist("A") =hwnd2)
winmove,ahk_id %hwnd1%,,x2-w2,y2
}

2Guiclose:
Guiclose:
esc::ExitApp
User avatar
AlphaBravo
Posts: 586
Joined: 29 Sep 2013, 22:59

Re: Move GUIs together

21 Jul 2017, 09:08

DockA

Code: Select all

Gui, 1: +hwndhwnd1 +ToolWindow
Gui, 1: show , w250 h100 x100 y100 ,move one


Gui, 2: +hwndhwnd2  +ToolWindow
Gui, 2: Show, w250 h100 x400 y100 ,move two

DockA(hwnd1, hwnd2)
DockA(hwnd2, hwnd1)
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: rc76 and 215 guests