AutoXYWH() - Move control automatically when GUI resized

Post your working scripts, libraries and tools
tmplinshi
Posts: 1064
Joined: 01 Oct 2013, 14:57

AutoXYWH() - Move control automatically when GUI resized

20 Dec 2013, 06:39

This is a simple version of Anchor() by Titan.

Old version


Modified version by toralf:

Code: [Select all] [Expand] [Download] (AutoXYWH.ahk)GeSHi © Codebox Plus



Example:

Code: [Select all] [Expand] [Download] (Untitled.ahk)GeSHi © Codebox Plus

Last edited by tmplinshi on 28 May 2015, 22:57, edited 11 times in total.
Rindis
Posts: 40
Joined: 23 Dec 2013, 13:58
Location: Norway

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

23 Dec 2013, 14:28

Hi
I can't get this to work. I get an error saying "Call to non existent function" in this line:

cInfo[ctrl] := { _x:(_x), _y:(_y), _w:(_w), _h:(_h), _a:StrSplit(_a) }


Cheers
tmplinshi
Posts: 1064
Joined: 01 Oct 2013, 14:57

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

23 Dec 2013, 14:31

Hello, Rindis
Please use latest version of AHK. Download link: http://l.autohotkey.net/AutoHotkey_L_Install.exe
User avatar
gregster
Posts: 216
Joined: 30 Sep 2013, 06:48

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

23 Dec 2013, 14:33

As far as I know, StrSplit() - as a function - is relatively new to AHK (the corresponding command is older) . You probably need AHK 1.1.13.01, like it is mentioned in the script header. So, update...!
Rindis
Posts: 40
Joined: 23 Dec 2013, 13:58
Location: Norway

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

23 Dec 2013, 14:39

:oops: Thank. Now updated and its working

Cheers
toralf
Posts: 432
Joined: 27 Apr 2014, 21:08
Location: Germany

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

25 Jun 2014, 13:41

Dear tmplinshi,

your code is nice, but it doesn't support fractions of dimensions, e.g. w0.5 = control gets only half of the gui width change.
Have you considered to expend your function in this direction?
ciao
toralf
User avatar
joedf
Posts: 5675
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

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

25 Jun 2014, 15:03

Nice!
@toralf true... But then, doesn't anchor do that?
toralf
Posts: 432
Joined: 27 Apr 2014, 21:08
Location: Germany

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

25 Jun 2014, 15:37

@joedf
Yes, but much more complicated. The lastest version of Anchor() is very complex code (i assume it got further optimized for speed). This version is simple and uses the latest features of AHK. And it allows to give a list of controls at once.

I went ahead an made a mod.

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

Last edited by toralf on 30 Jun 2014, 22:22, edited 4 times in total.
ciao
toralf
User avatar
joedf
Posts: 5675
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

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

25 Jun 2014, 15:55

nice mod! :D
guest3456
Posts: 1998
Joined: 09 Oct 2013, 10:31

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

25 Jun 2014, 16:03

can probably use this at the top of scripts requiring later AHK versions:

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

if (A_AhkVersion < "1.1.13.01")
MsgBox, This script/func requires AHK v1.1.13.01 or greater


http://ahkscript.org/docs/Variables.htm#AhkVersion

tmplinshi
Posts: 1064
Joined: 01 Oct 2013, 14:57

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

26 Jun 2014, 06:06

@toralf
Thanks for share. Your version looks much better.
toralf
Posts: 432
Joined: 27 Apr 2014, 21:08
Location: Germany

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

26 Jun 2014, 08:06

Fame is all to you, you started this.

here is a another mod with variadic list. I removed the redraw option.

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

Last edited by toralf on 30 Jun 2014, 22:23, edited 4 times in total.
ciao
toralf
User avatar
joedf
Posts: 5675
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

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

26 Jun 2014, 09:42

Nice! It's shaping!
just me
Posts: 4454
Joined: 02 Oct 2013, 08:51
Location: Germany

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

27 Jun 2014, 07:38

Awesome code! But, since vLabels, ClassNNs, and text are permitted as control identifiers, I suggest to consider the Gui.
toralf
Posts: 432
Joined: 27 Apr 2014, 21:08
Location: Germany

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

27 Jun 2014, 08:00

I was thinking of it too, but GuiControlGet works on the default Gui. I decided to leave it to the user to define a differnt Gui as default

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

Gui, GuiName:Default
just before the function is called *not tested*. I assume in most cases this will not be nessecary, because the GuiSize thread will be set it's own Gui as the default. So only in the rare cases that you want to control a second gui size by resizing the first gui you would need to define a different default gui. (do not even know if that would work, since A_GuiWidth and A_GuiHeight would be of the first gui)
Does this makes sense?
Overall, I believe it is not required. Do you agree?
ciao
toralf
just me
Posts: 4454
Joined: 02 Oct 2013, 08:51
Location: Germany

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

27 Jun 2014, 08:48

It's permitted to use the same vLabel and control text in different Guis. Also, ClassNNs like Edit1 or Button1 aren't necessarily unique. But only the first of two or more identical control identifiers will be stored, and possibly used for the wrong Gui. That's what I thought about.
toralf
Posts: 432
Joined: 27 Apr 2014, 21:08
Location: Germany

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

28 Jun 2014, 12:11

Good point. I'll fix it.
ciao
toralf
toralf
Posts: 432
Joined: 27 Apr 2014, 21:08
Location: Germany

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

28 Jun 2014, 20:06

I hope I fixed both of my two functions above. Could not test it yet, I'm only on my phone.
ciao
toralf
just me
Posts: 4454
Joined: 02 Oct 2013, 08:51
Location: Germany

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

30 Jun 2014, 03:21

It's working on A32, U32, and U64.
toralf
Posts: 432
Joined: 27 Apr 2014, 21:08
Location: Germany

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

01 Jul 2014, 14:36

This version removes some of the flickering by reducing the MoveDraw to only controls of class 'Button' (since Groupboxes are of class 'Button').

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

ciao
toralf

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 20 guests