AutoXYWH() - Move control automatically when GUI resized

Post your working scripts, libraries and tools
User avatar
joedf
Posts: 6132
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

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

12 Oct 2016, 15:09

Hmmm, true... it is unspecified. I am assuming it is on a simple "attribution" basis?
tmplinshi
Posts: 1100
Joined: 01 Oct 2013, 14:57

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

12 Oct 2016, 23:28

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

NO
egocarib
Posts: 86
Joined: 21 May 2015, 18:21

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

20 Oct 2016, 07:24

Using the lastest AHKv2, I get a "no object to invoke" error at the beginning of the outer For loop on this line:

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

If ( cInfo[ctrlID].x = "" ){


I fixed the issue by adding the following line immediately before it:

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

if !IsObject(cInfo[ctrlID]), cInfo[ctrlID] := {}


Not sure if you intended for AHKv2 compatibility or not, but I figured I'd mention the fix in case it's helpful to anyone else. (The AHKv2 documentation actually links to this thread).
User avatar
Alguimist
Posts: 205
Joined: 05 Oct 2015, 16:41

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

13 Jan 2018, 11:57

GuiControl, Move moves the control relatively to the parent window. Controls placed in a Tab3 control are then misplaced because the parent window is a child dialog. This issue can be solved with a modified version of AutoXYWH:

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


Notice the use of the "t" option.
toralf
Posts: 440
Joined: 27 Apr 2014, 21:08
Location: Germany

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

13 Jan 2018, 15:59

Thanks for the addition
ciao
toralf
pramach
Posts: 39
Joined: 24 Jan 2018, 08:20

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

31 Jan 2018, 10:11

Hi

I needed to add an additional init code line, otherwise I got an warning

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

If (cInfo[ctrlID].x = "") {
ix := iy := iw := ih := 0 ;; added to prevent warning

---------------------------
TimeReport.ahk
---------------------------
Warning in #include file "AutoXYWH.ahk":
This variable has not been assigned a value.

Specifically: ix (a local variable)

Line#
045: hParentWnd := DllCall("GetParent", "Ptr", hWnd, "Ptr")
046: VarSetCapacity(RECT, 16, 0)
047: DllCall("GetWindowRect", "Ptr", hParentWnd, "Ptr", &RECT)
048: DllCall("MapWindowPoints", "Ptr", 0, "Ptr", DllCall("GetParent", "Ptr", hParentWnd, "Ptr"), "Ptr", &RECT, "UInt", 1)
049: ix := ix - NumGet(RECT, 0, "Int")
050: iy := iy - NumGet(RECT, 4, "Int")
051: }
---> 053: 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}
054: }
054: Else
054: if (cInfo[ctrlID].a.1)
054: {
055: dgx := dgw := A_GuiWidth - cInfo[ctrlID].gw, dgy := dgh := A_GuiHeight - cInfo[ctrlID].gh
056: Options := ""
057: For i,dim in cInfo[ctrlID]["a"]

For more details, read the documentation for #Warn.
---------------------------
OK
---------------------------


Just for info.

And thanks for code providing.
ahklearner
Posts: 269
Joined: 23 Jan 2015, 01:49

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

06 Feb 2018, 06:21

where can I find the updated and latest version, please :)
pramach
Posts: 39
Joined: 24 Jan 2018, 08:20

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

07 Feb 2018, 01:48

ahklearner wrote:where can I find the updated and latest version, please :)

First post of this thread.

I just added the additional init line (ix:= iy:= ...) after the "if" as mentioned in my post above yours.
It works exactly the same with and without my init line, however if you have a #Warn statement in your main script than you got the warning like I have posted too.
With these init line, you don't get THIS warning (but maybe others in other functions or lines of your code).
User avatar
SL5
Posts: 132
Joined: 12 May 2015, 02:10
GitHub: sl5net
Contact:

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

07 Feb 2018, 02:29

what about create a loop or setinterval?
and check always the size?
pramach
Posts: 39
Joined: 24 Jan 2018, 08:20

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

07 Feb 2018, 02:46

SL5 wrote:what about create a loop or setinterval? and check always the size?


To do what ?

The GuiSize is already a kind of trigger called by AHK in case the GUI is resized.
User avatar
SL5
Posts: 132
Joined: 12 May 2015, 02:10
GitHub: sl5net
Contact:

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

07 Feb 2018, 02:54

pramach wrote:
SL5 wrote:what about create a loop or setinterval? and check always the size?

The GuiSize is already a kind of trigger called by AHK in case the GUI is resized.

sorry i missunderstud.
may close the control and start again?
pramach
Posts: 39
Joined: 24 Jan 2018, 08:20

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

07 Feb 2018, 03:11

SL5 wrote:sorry i missunderstud.
may close the control and start again?


Sorry but now I do not understand your wish !
pramach
Posts: 39
Joined: 24 Jan 2018, 08:20

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

07 Feb 2018, 03:13

Btw, du kannst auch im deutschen Forum einen Thread dazu eröffnen ;-)
ahklearner
Posts: 269
Joined: 23 Jan 2015, 01:49

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

07 Feb 2018, 05:22

Please help me with this.

What should be correct version for this
AutoXYWH("why", "e1","e2")
AutoXYWH("yw", "b1","b2","b3","b4")



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

pramach
Posts: 39
Joined: 24 Jan 2018, 08:20

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

07 Feb 2018, 06:06

Don't know if this is the most elegant way to solve it ...
But I would do it like that.

As the clist in AutoXYWH function is not optional, you have to pass an empty control list.

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

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

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

07 Feb 2018, 06:15

Try this:

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

AutoXYWH("wh0.5", "e1")
AutoXYWH("wh0.5y0.5", "e2")
AutoXYWH("*w0.25y", "b1")
AutoXYWH("*w0.25yx0.25", "b2")
AutoXYWH("*w0.25yx0.5", "b3")
AutoXYWH("*w0.25yx0.75", "b4")
I hope that helps.
ahklearner
Posts: 269
Joined: 23 Jan 2015, 01:49

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

07 Feb 2018, 06:24

Thanks a lot "wolf_II & pramach" for guidance.
I appreciate your time and efforts.

wolf_II wrote:Try this:

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

AutoXYWH("wh0.5", "e1")
AutoXYWH("wh0.5y0.5", "e2")
AutoXYWH("*w0.25y", "b1")
AutoXYWH("*w0.25yx0.25", "b2")
AutoXYWH("*w0.25yx0.5", "b3")
AutoXYWH("*w0.25yx0.75", "b4")
I hope that helps.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: Maasq and 15 guests