AutoXYWH() - Move control automatically when GUI resized

Post your working scripts, libraries and tools
toralf
Posts: 440
Joined: 27 Apr 2014, 21:08
Location: Germany

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

01 Jul 2014, 17:02

Could someone with experience run a speed comparison against anchor() please? I have no real exp.
ciao
toralf
toralf
Posts: 440
Joined: 27 Apr 2014, 21:08
Location: Germany

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

03 Jul 2014, 07:35

And another version.
The previous seemed to be overkill to redraw every control in Class 'Button' and storing too much unneeded data in the cInfo object.
Thus, for this version you will have to specify a * in DimSize to MoveDraw the controls rather then Move, which is recommended for groupboxes.

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

ciao
toralf
User avatar
evilC
Posts: 4104
Joined: 27 Feb 2014, 12:30

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

04 Feb 2015, 22:29

Yes, this is much neater than Anchor, thanks!

Nice to see it also works with HWNDS ;)

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



Though personally I would make ctrl_list an indexed array - pipe delimited lists is a bit old-school surely?

Also, I used this to *almost* solve the issue of AHK not supporting scrollbars for GUIs.
The idea is to hijack a listview and insert images into the listview of a known height.
You then inject your controls, guis etc into the LV, and set the rows of the LV to the height of your GUI, and it handles the scrollbars for you.
You then use AutoXYWH to make the LV always fill the GUI.
Only problem is, the contents corrupt when the LV scrolls. If anyone can think of any solutions, please see my thread here: viewtopic.php?f=5&t=6297&p=37205#p37205
toralf
Posts: 440
Joined: 27 Apr 2014, 21:08
Location: Germany

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

05 Feb 2015, 04:56

Wouldn't your post better be placed in the ask for help section instead of highjacking this thread?
ciao
toralf
m3user
Posts: 107
Joined: 17 Jan 2014, 18:11

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

07 Feb 2015, 07:51

Hi, great function! I have one question:

When some gui control (for example Edit control) in a window gets resized, the function does not work properly (doesn't consider the changed size of control). The problem was the same with Anchor. Please try the example below - press the button and then resize.
Any solution to this? How could this be solved? Thanks!

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

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

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

07 Feb 2015, 11:07

To m3user.
What you want is not supported by this function. You would need to change the function by e.g. adding a new parameter to reset the original size.
ciao
toralf
m3user
Posts: 107
Joined: 17 Jan 2014, 18:11

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

07 Feb 2015, 13:34

Thanks Toralf, I have no idea how to do this. Any help is appreciated. :-)
think
Posts: 28
Joined: 09 Feb 2014, 05:20

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

22 Feb 2015, 04:37

Thanks for this function, it finally sends Anchor to retirement. However I agree, it needs a reset option - would it be difficult to add?
toralf
Posts: 440
Joined: 27 Apr 2014, 21:08
Location: Germany

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

22 Feb 2015, 08:26

In general it should be possible. Somehow the function needs to know when that will be. Since the second parameter is an array the info has to be in the first parameter. Which would also make sense since it would be a reset of the dimensions.
What would be your suggestion on how to provide the info in the first parameter? E.g. an 'r' or a '*'?

But before something gets developed that is not needed please help to define the details:
When would a reset be required in addition to the above case? Why would it need to be reset? And what needs to be reset?
ciao
toralf
think
Posts: 28
Joined: 09 Feb 2014, 05:20

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

23 Feb 2015, 09:13

The example posted above shows the issue clearly.

Reset could be called after any re-arrangement of the controls in gui window (typically by GuiControl, Move) by calling AutoXYWH("r", "e1") or similar after a resize or by simply calling AutoXYWH().
Guest

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

01 Mar 2015, 22:22

Nice job!
Is it possible add/improve the following functions?
1. Set minimum GUI size to prevent controls squeezing together.
2. Set positions of multiple controls. for example: AutoXYWH("xy", "Button1-30" , "Edit1-30")
3. Eliminate blinking during resizing.

Thanks!
toralf
Posts: 440
Joined: 27 Apr 2014, 21:08
Location: Germany

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

01 Mar 2015, 22:48

1) can be done via Gui, MinSize
2) I do not understand. Please elaborate
3) not possible
ciao
toralf
Guest

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

02 Mar 2015, 08:45

Thank you toralf,
toralf wrote:2) I do not understand. Please elaborate


Imagine that I have a GUI has 30 buttons and 30 edit boxes.

Currently I'm using code like this:

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

AutoXYWH("xy", "Button1" , "Button2","Button3" , "Button4".......)
AutoXYWH("xy", "Edit1" , "Edit2","Edit3" , "Edit4".......)


It will be nice it we can use the short code below:

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

AutoXYWH("xy", "Button1-30" , "Edit1-30")
just me
Posts: 5348
Joined: 02 Oct 2013, 08:51
Location: Germany

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

02 Mar 2015, 09:04

Guest wrote:Imagine that I have a GUI has 30 buttons and 30 edit boxes.

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

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

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

02 Mar 2015, 14:08

Thanks just me.
AutoXYWH() is already a variadic function. Thus what just me wrote could directly be used with it.
ciao
toralf
toralf
Posts: 440
Joined: 27 Apr 2014, 21:08
Location: Germany

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

02 Mar 2015, 14:11

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

Controls := []
Loop, 30
Controls.Insert("Button" . A_Index), Controls.Insert("Edit" . A_Index)
AutoXYWH("xy", Controls*)
ciao
toralf
danielo515
Posts: 58
Joined: 18 Feb 2015, 15:06

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

26 Apr 2015, 06:55

Does this function have problems with Named GUIs?

Something like
gui,mainGui:new

After I named the gui that way it stopped working.
toralf
Posts: 440
Joined: 27 Apr 2014, 21:08
Location: Germany

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

26 Apr 2015, 07:22

I think it should not, but could you please post a short sample code that shows the problem?
ciao
toralf

Return to “Scripts and Functions”

Who is online

Users browsing this forum: DataLife, swagfag and 8 guests