
Control Anchoring v4 for resizing windows
Download

* Just updated, it works much better now
I use it and another function almost just like it to resize one of my GUI's. It has 29 controls (that are run through the functions) including one listview and four tabs. Works great!

One thing that I did because I'm so lazy, is changed the order of the params to the function...
From:
Anchor(Control, Anchors="", x=0, y=0, w=0, h=0)
To:
Anchor(x=0, y=0, w=0, h=0, Control, Anchors="")
This made it a bit easier to create the call for most of the controls since it somewhat follows the format of most of my GUI, Add statements. That is, the x-y-h-w coords first usually followed by a variable name. Using a few find and replace statements with my editor could then do most of the work. Hope that makes sense... :roll:

The open source is there so you can customize it to your needs :wink:. Glad you liked it anyway.One thing that I did because I'm so lazy, is changed the order or params to the function...


Bob


Does this library already exist?It should probably be one of the things put in the forthcoming library of standard include files.
___________________
Cheers
AGU

I meanwhile took your old function and replaced GuiControl, Move with GuiControl, MoveDraw to workaround a displaying error when resizing the GUI in x-direction.
This is your older one:
Anchor(Control, Anchors="", x=0, y=0, w=0, h=0) { ; Thanks to Titan for this function ; Details under http://www.autohotkey.com/forum/viewtopic.php?p=26778 ; Control : Variable assigned to the control (e.g. "MyEdit") ; Anchors : How control to be moved (e.g. "xy" for position or "wh" for size) ; x, y, w, h : respective values of control ; (note you can omit values that aren't needed by the Anchors by putting any value) global GuiW, GuiH If (not Anchors) Anchors = xy If Anchors contains x GuiControl, MoveDraw, % Control, % "x" x+(A_GuiWidth-GuiW) If Anchors contains y GuiControl, MoveDraw, % Control, % "y" y+(A_GuiHeight-GuiH) If Anchors contains w GuiControl, MoveDraw, % Control, % "w" w+(A_GuiWidth-GuiW) If Anchors contains h GuiControl, MoveDraw, % Control, % "h" h+(A_GuiHeight-GuiH) }
I call it this way:
... Anchor("EdtComment", "wh", 0, 0, EdtW, EdtH) Anchor("GrpMenuBorder", "w", 0, 0, GrpW, 0) Anchor("ChkSig", "y", 0, ChkY, 0, 0) Anchor("DDLSig", "y", 0, DDLY, 0, 0) Anchor("BtnEditSig", "y", 0, BSgY, 0, 0) Anchor("BtnDelSig", "y", 0, BSgY, 0, 0) Anchor("BtnSend", "xy", BG1X, BG3Y, 0, 0) Anchor("BtnPreview", "xy", BG2X, BG3Y, 0, 0) Anchor("BtnReset", "xy", BG3X, BG3Y, 0, 0) Anchor("BtnPinned", "x", BG4X, 0, 0, 0) ...
How would I have to call your updated function? I tried to remove all anchors to make the syntax compatible to your new function but it didn't work.
Anchor("EdtComment", 0, 0, EdtW, EdtH)_______________
Cheers
AGU


autohotkey.com/net Site Manager
Contact me by email (polyethene at autohotkey.net) or message tidbit
btw. wouldn't it be better to set Draw to 1? Because I spotted this displaying error when resizing a GUI in x-direction when using a normal move instead of a MoveDraw.

Therefore I predefined Draw to 1:
Anchor(Control, x=0, y=0, w=0, h=0, Draw=1) { ; Thanks to Titan for this function ; Details under http://www.autohotkey.com/forum/viewtopic.php?p=26778 ; Control : Variable assigned to the control (e.g. "MyEdit") ; x, y, w, h : the anchor positions/dimensions ; Draw : false/0 to use Move otherwise leave blank for a MoveDraw global GuiW, GuiH IfEqual, GuiW { SetEnv, GuiW, %A_GuiWidth% } IfEqual, GuiH { SetEnv, GuiH, %A_GuiHeight% } pos = xywh Loop, Parse, pos { If (%A_LoopField% != "") { If A_LoopField in x,w { v := %A_LoopField% + (A_GuiWidth - GuiW) } Else { v := %A_LoopField% + (A_GuiHeight - GuiH) } move := move . A_LoopField . v } IfNotEqual, Draw, 0 { SetEnv, MDraw, Draw } } GuiControl, Move%MDraw%, %Control%, %move% Return, ErrorLevel }__________________
Cheers
AGU


autohotkey.com/net Site Manager
Contact me by email (polyethene at autohotkey.net) or message tidbit
Older versions are still available for download.

autohotkey.com/net Site Manager
Contact me by email (polyethene at autohotkey.net) or message tidbit
I got late in testing out this nice function... its very well-made and works great.. thanks for posting!

CleanNews.in : Bite sized latest news headlines from India with zero bloat

autohotkey.com/net Site Manager
Contact me by email (polyethene at autohotkey.net) or message tidbit

autohotkey.com/net Site Manager
Contact me by email (polyethene at autohotkey.net) or message tidbit