Width and height of the edits are changing with the gui.
Code: Select all
Gui, +Resize
Gui, Margin , 5, 5
Gui, Add, Edit, w90 h30 vEdts1, Edits1
Gui, Add, Edit, x+ w90 h30 vEdts2, Edits2
Gui, Add, Edit, x+ w50 h30 vEdts3, Edits3
Gui, Add, Edit, x+ w90 h30 vEdts4, Edits4
Gui, Add, Edit, x+ w90 h30 vEdts5, Edits5
Gui, Add, Edit, x+ w130 h30 vEdts6, Edits6
Gui, Add, Button, x5 y50 w90 h30 vBtn1, Button1
Gui, Add, Button, x+ y50 w90 h30 vBtn2, Button2
Gui, Add, Button, x+ y50 w50 h30 vBtn3, Button3
Gui, Add, Button, x+ y50 w90 h30 vBtn4, Button4
Gui, Add, Button, x+ y50 w90 h30 vBtn5, Button5
Gui, Add, Button, x+ y50 w130 h30 vBtn6, Button6
Gui, Show, h150 w550, Edits in a row
return
GuiClose:
ExitApp
return
Guisize:
;for six Edits
edts := []
Btns := []
Loop, 6
edts.Insert("edts" . A_Index), Btns.Insert("btn" . A_Index)
AutoXYWH("r h", edts*)
AutoXYWH("r y", Btns*)
;AutoXYWH("r h", "edts1","edts2","edts3","edts4","edts5","edts6")
return
; =================================================================================
; Function: AutoXYWH
; Move and resize control automatically when GUI resizes.
; Parameters:
; DimSize - Can be one or more of x/y/w/h optional followed by a fraction
; add a '*' to DimSize to 'MoveDraw' the controls rather then just 'Move', this is recommended for Groupboxes
; cList - variadic list of ControlIDs
; ControlID can be a control HWND, associated variable name, ClassNN or displayed text.
; The later (displayed text) is possible but not recommend since not very reliable
; Examples:
; AutoXYWH("xy", "Btn1", "Btn2")
; AutoXYWH("w0.5 h 0.75", hEdit, "displayed text", "vLabel", "Button1")
; AutoXYWH("*w0.5 h 0.75", hGroupbox1, "GrbChoices")
; ---------------------------------------------------------------------------------
; Version: 2015-5-29 / Added 'reset' option (by tmplinshi)
; 2014-7-03 / toralf
; 2014-1-2 / tmplinshi
; requires AHK version : 1.1.13.01+
; =================================================================================
AutoXYWH(DimSize, cList*){ ; http://ahkscript.org/boards/viewtopic.php?t=1079
static cInfo := {}
If (DimSize = "reset")
Return cInfo := {}
;==========
dms:= strReplace(DimSize,"r","")
;==========
For i, ctrl in cList {
ctrlID := A_Gui ":" ctrl
If ( cInfo[ctrlID].x = "" ){
GuiControlGet, i, %A_Gui%:Pos, %ctrl%
MMD := InStr(DimSize, "*") ? "MoveDraw" : "Move"
; ==========
Row := (i=1) ? "w" . 1/cList.MaxIndex() : "x" . (i-1)/cList.MaxIndex() . " w" . 1/cList.MaxIndex() . " "
IF (InStr(DimSize, "r"))
DimSize:=dms . " " . Row . " r"
; ==========
fx := fy := fw := fh := 0
For i, dim in (a := StrSplit(RegExReplace(DimSize, "i)[^xywh]")))
If !RegExMatch(DimSize, "i)" dim "\s*\K[\d.-]+", f%dim%)
f%dim% := 1
cInfo[ctrlID] := { x:ix, fx:fx, y:iy, fy:fy, w:iw, fw:fw, h:ih, fh:fh, gw:A_GuiWidth, gh:A_GuiHeight, a:a , m:MMD}
}Else If ( cInfo[ctrlID].a.1) {
dgx := dgw := A_GuiWidth - cInfo[ctrlID].gw , dgy := dgh := A_GuiHeight - cInfo[ctrlID].gh
For i, dim in cInfo[ctrlID]["a"]
Options .= dim (dg%dim% * cInfo[ctrlID]["f" dim] + cInfo[ctrlID][dim]) A_Space
GuiControl, % A_Gui ":" cInfo[ctrlID].m , % ctrl, % Options
} } }