Skip to content

Instantly share code, notes, and snippets.

@tmplinshi
Last active September 6, 2019 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmplinshi/3eed456467a8fac0147d1d09a4729cc2 to your computer and use it in GitHub Desktop.
Save tmplinshi/3eed456467a8fac0147d1d09a4729cc2 to your computer and use it in GitHub Desktop.
basic example of how to do auto sizing.
Gui, +Resize
Gui, Add, Edit, w250 h100 vEditField
Gui, Add, Button, Section, Start
Gui, Add, Button, yS, Stop
Gui, Show, Center
Return
GuiSize:
if !initSize {
GuiControlGet, c1, Pos, EditField
GuiControlGet, c2, Pos, Button1
GuiControlGet, c3, Pos, Button2
initSize := { "gui" : {w:A_GuiWidth, h:A_GuiHeight}
, "Edit1" : {x:c1X, y:c1Y, w:c1W, h:c1H}
, "Button1": {x:c2X, y:c2Y, w:c2W, h:c2H}
, "Button2": {x:c3X, y:c3Y, w:c3W, h:c3H} }
lastGuiW := A_GuiWidth
lastGuiH := A_GuiHeight
return
}
if (A_EventInfo = 1) ; The window has been minimized.
|| (A_GuiWidth = lastGuiW && A_GuiHeight = lastGuiH) { ; The window has been restored (from minimized state)
return
}
changedW := A_GuiWidth - initSize.gui.w
changedH := A_GuiHeight - initSize.gui.h
GuiControl, Move, EditField, % ("w" initSize.Edit1.w + changedW) . (" h" initSize.Edit1.h + changedH)
GuiControl, Move, Button1 , % ("y" initSize.Button1.y + changedH)
GuiControl, Move, Button2 , % ("y" initSize.Button2.y + changedH)
lastGuiW := A_GuiWidth
lastGuiH := A_GuiHeight
Return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment