AutoXYWH() - Move control automatically when GUI resized

Post your working scripts, libraries and tools
m3user
Posts: 107
Joined: 17 Jan 2014, 18:11

Re: AutoXYWH() - Move control automatically when GUI resized

12 Jun 2015, 14:54

Thanks. One question: I use a Scintilla wrapper class where hwnd of the control is retrieved as sci.hwnd.

I tried

Code: [Select all] [Download] GeSHi © Codebox Plus

AutoXYWH("wh", sc.hwnd)
; or
AutoXYWH("wh", "ahk_id " sc.hwnd)

for resizing it it but it does not work. Can anybody suggest how to do this? Thanks!
tmplinshi
Posts: 1218
Joined: 01 Oct 2013, 14:57

Re: AutoXYWH() - Move control automatically when GUI resized

12 Jun 2015, 21:05

@m3user
Try AutoXYWH("wh", "Scintilla1"). If this doesn't work, use AU3_Spy.exe to get the control info.
m3user
Posts: 107
Joined: 17 Jan 2014, 18:11

Re: AutoXYWH() - Move control automatically when GUI resized

13 Jun 2015, 06:41

Thanks tmplinshi, the ClassNN is Scintilla1 but unfortunately it doesn't work.
Guest1234

Re: AutoXYWH() - Move control automatically when GUI resized

21 Jun 2015, 16:34

Let me start out by saying thank you for this script. It's very nice. I seem to remember having issues with Anchor when I tried it a while back but this works like a dream. One thing that I'd like to point out, though really it's inconsequential, is that the function doesn't work correctly when #Warn is in the script. It complains that "This variable has not been assigned a value. Options (a local variable)". I've worked around this by simply initializing Options at the top of the function. Again, most users will not experience this. But again, thank you so much for this script.
haichen
Posts: 153
Joined: 09 Feb 2014, 08:24

Re: AutoXYWH() - Move control automatically when GUI resized

06 Jul 2015, 11:29

I would like to have an easy way to add controls into a row without thinking how to add the correct factors for w and x.
In the example there are no height corrections. So this code is only useful for Buttons I think.
Here is my try:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



May be you can add something like this to AUTXYWH()

Thanks a lot for this everyday used function!

Edit:Correct some very stupid Errors..
Edit:Now this works for h and y
haichen
Posts: 153
Joined: 09 Feb 2014, 08:24

Re: AutoXYWH() - Move control automatically when GUI resized

08 Jul 2015, 12:28

Buttons and Edits nicely aligned in two rows:
Width and height of the edits are changing with the gui.
The Buttons only changing the width and y-Position.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

User avatar
BGM
Posts: 419
Joined: 20 Nov 2013, 20:56
GitHub: bgmCoder
Contact:

Re: AutoXYWH() - Move control automatically when GUI resized

19 May 2016, 09:55

toralf,

I am having troubles. It works when I include it and run it as a script, but when I compile it, I get errors.

With autoxywh in the first post, I get:

Code: [Select all] [Download] GeSHi © Codebox Plus

Call to nonexistent function.
For i, dim in (a := StrSplit(RegExReplace(DimSize, "i)[^xywh]")))


and also with the version you posted on July 1, 2014:

Code: [Select all] [Download] GeSHi © Codebox Plus

Error: Call to nonexistent function.
Specifically: ACH := StrSplit(CH, "`n"), ACN := StrSplit(CN, "`n")

It doesn't like the strsplit() part.
I'm running AutoHotkey 1.1.23.03 Unicode on Windows 7 Pro x64

This happens if I just include the library, I don't even have to call the function.
User avatar
BGM
Posts: 419
Joined: 20 Nov 2013, 20:56
GitHub: bgmCoder
Contact:

Re: AutoXYWH() - Move control automatically when GUI resized

19 May 2016, 20:14

I figured it out with GeekDude's help.

I neglected to update the bin file (or my compilation script did, anyway).

It works!
highend
Posts: 43
Joined: 24 Nov 2014, 16:57

Re: AutoXYWH() - Move control automatically when GUI resized

24 Jul 2016, 07:06

Thanks a lot for this function!

I have two groupboxes (GB1 + GB2), each containing an edit element.
Resizing the groupboxes works fine and the same goes for the edit controls.
But...
I want the GB2 to move in y direction depending on how GB1 is resized so that they don't overlap.
Both edit controls should resize in their appropriate groupbox as well.

The problem is, that GB2 + e2 get to large for the gui's window when you resize the control too much (in height).

Is there anything I could do to not let that happen?

Sample code:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

wolf_II
Posts: 1975
Joined: 08 Feb 2015, 20:55

Re: AutoXYWH() - Move control automatically when GUI resized

24 Jul 2016, 07:19

Try this:

Code: [Select all] [Download] GeSHi © Codebox Plus

GuiSize:
If (A_EventInfo = 1) ; The window has been minimized.
Return
AutoXYWH("*wh0.5", "GB1")
AutoXYWH("*y0.5wh0.5", "GB2")
AutoXYWH("wh0.5", "e1")
AutoXYWH("y0.5wh0.5", "e2")
return
I hope that helps.
highend
Posts: 43
Joined: 24 Nov 2014, 16:57

Re: AutoXYWH() - Move control automatically when GUI resized

24 Jul 2016, 08:22

@wolf_II

With these commands it works as expected :)

Thanks a lot!
ahklearner
Posts: 279
Joined: 23 Jan 2015, 01:49

Re: AutoXYWH() - Move control automatically when GUI resized

24 Sep 2016, 02:45

i am wondering why it is not positioning y of edit boxes, when i have added multiple boxes, it should be like y+10 once height and width are resized.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



It would be better if it calculates width according to percentage of the gui width changed.
and please guide me how to change height of 3rd edit control according to gui height, but not changing height of 1st and 2nd edit box.

Thanks in advance for your help and support.
wolf_II
Posts: 1975
Joined: 08 Feb 2015, 20:55

Re: AutoXYWH() - Move control automatically when GUI resized

24 Sep 2016, 03:04

Try this:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

I hope that helps.
ahklearner
Posts: 279
Joined: 23 Jan 2015, 01:49

Re: AutoXYWH() - Move control automatically when GUI resized

24 Sep 2016, 03:18

ahklearner wrote:but not changing height of 1st and 2nd edit box.


Wondering :bravo:
ahklearner
Posts: 279
Joined: 23 Jan 2015, 01:49

Re: AutoXYWH() - Move control automatically when GUI resized

24 Sep 2016, 03:55

Code: [Select all] [Download] GeSHi © Codebox Plus

    AutoXYWH("w0.5", "e1")
AutoXYWH("x0.5w0.5", "e2")
AutoXYWH("y+10.5w0.5h0.5", "e3")
AutoXYWH("*y", "b1")


for height i tried this, but the next control is not Y+10.

a lil explanation would be very helpful.
tmplinshi
Posts: 1218
Joined: 01 Oct 2013, 14:57

Re: AutoXYWH() - Move control automatically when GUI resized

24 Sep 2016, 04:59

I don't understand how you want to deal with Y+10.

Lets say...

Gui_Height = 100
Control_Y = 30

With AutoXYWH("y", "Control"), when Gui_Height changes to 200, the Control_Y will be 130. Similarly Gui_Height=300 then Control_Y=230.
But...
With AutoXYWH("y+10", "Control"), when Gui_Height changes to 200, what's the value of Control_Y you expecting? And Gui_Height=300 then Control_Y=?

Percentage changing is the only valid way, isn't it? Not + or -.
haichen
Posts: 153
Joined: 09 Feb 2014, 08:24

Re: AutoXYWH() - Move control automatically when GUI resized

08 Oct 2016, 07:54

Code: [Select all] [Download] GeSHi © Codebox Plus

    }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
}


shouldn't there be an Options:="" before the loop?
wolf_II
Posts: 1975
Joined: 08 Feb 2015, 20:55

Re: AutoXYWH() - Move control automatically when GUI resized

08 Oct 2016, 08:21

There is an Options := "" before the loop. It is done by AHK itself. All local variables inside a function are initialized with an empty string.

see Local
haichen
Posts: 153
Joined: 09 Feb 2014, 08:24

Re: AutoXYWH() - Move control automatically when GUI resized

08 Oct 2016, 09:39

You're of course right. Only cInfo was static.
Thank you, and sorry.
drawback
Posts: 31
Joined: 11 Aug 2016, 11:31

Re: AutoXYWH() - Move control automatically when GUI resized

12 Oct 2016, 14:12

Are there any license restrictions (for using it in a commercial application) for this one?

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 18 guests