Doubt about GUI alignment with x+ y+

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kauan014
Posts: 55
Joined: 18 Feb 2021, 20:03

Doubt about GUI alignment with x+ y+

17 Mar 2022, 21:36

Code: Select all

Gui, Color, 0
Gui, +E0x02000000 +E0x00080000


Gui, Font, s20, Tahoma
Gui, Add, Text, x10 y10 cRed, GROUP 1
Gui, Font, s8, Tahoma

; -----------------------------------------------
; Group 1
Gui, Add, ListBox, x10 y+10 w100 h40 hWndB1, A|B|C
MyClass.Test(B1, 100, 60)
GuiControlGet, Pos, Pos, %B1%
FileAppend, X: %PosX% Y: %PosY% W: %PosW% H: %PosH%`n,*
Gui, Add, Button, y+10 w100 h40, Button



; ---------
Gui, Font, s20, Tahoma
Gui, Add, Text, x200 y10 cRed, GROUP 2
Gui, Font, s8, Tahoma



; -----------------------------------------------
; Group 2
Gui, Add, ListBox, x200 y+10 w100 h60, A|B|C
Gui, Add, Button,   xp  y+10 w100 h40, Button
; -----------------------------------------------
Gui, Show, w400 h200, GUI


Return

Class MyClass {

   Test(hWnd, W, H) {
      GuiControl, MoveDraw, %hWnd%, w%W% h%h%
   }

}
image.png
image.png (7.22 KiB) Viewed 334 times
Why in group1:
Gui, Add, Button, y+10 w100 h40, Button
the y+10 dont align the control as in group2?
as the height of the listbox has been modified from 40 to 60 before the button control has been created?



What i could do, to any new control being created with x+ or y+ take as base the height modified by GuiControl, Move ?
Hardcoder
Posts: 278
Joined: 19 Feb 2022, 13:13
Location: Germany

Re: Doubt about GUI alignment with x+ y+

18 Mar 2022, 03:26

Hi, pretty sure that's not possible by default, but take a look at this:
AutoXYWH() - Move control automatically when GUI resized
just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Doubt about GUI alignment with x+ y+

18 Mar 2022, 04:32

The values used by relative positioning are stored internally when controls are created. Later GuiControlMove commands do not change them.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: apeironn, peter_ahk and 329 guests