AutoXYWH() - Move control automatically when GUI resized

Post your working scripts, libraries and tools for AHK v1.1 and older
danielo515
Posts: 58
Joined: 18 Feb 2015, 15:06

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

26 Apr 2015, 07:47

Hello toralf,

It's not a problem with your script, it's a problem with AHK documentation. It's very hard to figure out that each window has it's ow guisize label. Once I added the name of the gui as a prefix of the guisize label you script started to work again. Not very intuitive in my opinion
toralf
Posts: 868
Joined: 27 Apr 2014, 21:08
Location: Germany

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

26 Apr 2015, 12:10

Actually I think it is simple.
What would you suggest should change?
ciao
toralf
danielo515
Posts: 58
Joined: 18 Feb 2015, 15:06

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

27 Apr 2015, 03:51

toralf wrote:Actually I think it is simple.
What would you suggest should change?
Sorry if I was not clear. You script is working perfectly. What should be changed is AHK documentation.

Regards
Guest

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

27 Apr 2015, 06:21

Only the first one works as expected.
Dont know if its my fault, but it drives me crazy.

Code: Select all

	html:="fadfsf dfsdf  dfssdf dfsd fsdf fsd fsdf fsdf df dfsd fd f sdf dsf asf  fsdf f sdfsd f"
	
	Gui,  +Resize 
	document1 := ComObjCreate("InternetExplorer.Application")
	Gui,  Add, ActiveX,  h100 w100  vdocument1 hwndhTest1, HTMLFile
	document1.write(html)
	Gui,  Show, x800, test1
	
	Gui, web:new
	Gui, web:Default
	Gui,  +Resize 
	document2 := ComObjCreate("InternetExplorer.Application")
	Gui,  Add, ActiveX,   h100 w100  vdocument2 hwndhTest2, HTMLFile
	document2.write(html)
	Gui,  Show, x1000, test2
	
	Gui, net:new
	Gui, net:  +Resize 
	document3 := ComObjCreate("InternetExplorer.Application")
	Gui,net:  Add, ActiveX,   h100 w100  vdocument3 hwndhTest3, HTMLFile
	document3.write(html)
	Gui, net: Show, x1300, test3
	return
	
	GuiSize:
	AutoXYWH("wh", htest1)
	AutoXYWH("wh", htest2)
	AutoXYWH("wh", htest3)
	Return
toralf
Posts: 868
Joined: 27 Apr 2014, 21:08
Location: Germany

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

27 Apr 2015, 06:47

You will need to add WebGuiSize and NetGuiSize.
Each of the guisize subroutines will have only one AutoXYWH().
ciao
toralf
Guest

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

27 Apr 2015, 07:43

Thank you very much.
I knew that, but i totally forget that fact. And i read it in the docs but dont mention it. Not my day.
danielo515
Posts: 58
Joined: 18 Feb 2015, 15:06

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

30 Apr 2015, 07:55

Hello Everyone.

This still not working for width of controls on the same "row". I tried with every kind of combination. Any Idea about what I'm doing wrong?
tmplinshi
Posts: 1604
Joined: 01 Oct 2013, 14:57

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

30 Apr 2015, 08:31

danielo515 wrote:Hello Everyone.

This still not working for width of controls on the same "row". I tried with every kind of combination. Any Idea about what I'm doing wrong?
Note: Please use the modified version by toralf to test below examples.
Resize two controls's width at same row
Resize three controls's width at same row
danielo515
Posts: 58
Joined: 18 Feb 2015, 15:06

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

30 Apr 2015, 10:42

Hello tmplinshi

Wow, I can't believe I have been so stupid! I have been using 0.5w and 0.5x as options instead of w0.5 and x0.5!!

Now I have others problems to face. Thank you.
User avatar
BGM
Posts: 507
Joined: 20 Nov 2013, 20:56
Contact:

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

12 May 2015, 23:43

In my case, I need three controls in a row to size proportionally, but I need the last control to be anchored to the previous control instead of anchored to "x".
In other words, in this case, Edit3's leftmost position should be 4 pixels from the rightmost edge of Edit2.
Is it possible to add a feature to anchor to another control's border?
Or maybe it could be made to anchor to the right side of the window?

Code: Select all

#include lib\autoxywh.ahk

Gui, +Resize
Gui, Add, Edit, HwndHEdit1,
Gui, Add, Edit, x+4 HwndHEdit2,
Gui, Add, Edit, x+4 HwndHEdit3,
Gui, Show
Return

GuiSize:
    AutoXYWH("w", HEdit1)
    AutoXYWH("xw", HEdit2)
 	AutoXYWH("xw", HEdit3)
Return

GuiClose:
ExitApp
tmplinshi
Posts: 1604
Joined: 01 Oct 2013, 14:57

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

13 May 2015, 03:35

@BGM

Code: Select all

    AutoXYWH("w0.33", HEdit1)
    AutoXYWH("x0.33 w0.33", HEdit2)
    AutoXYWH("x0.66 w0.33", HEdit3)
User avatar
BGM
Posts: 507
Joined: 20 Nov 2013, 20:56
Contact:

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

13 May 2015, 09:56

Thanks! That gives me some ideas. I actually had read about using percentages but I didn't get it. Now I get it.
User avatar
BGM
Posts: 507
Joined: 20 Nov 2013, 20:56
Contact:

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

16 May 2015, 10:43

Hmmm... I was hoping to do some tricks with two edit controls.
Take a look at my example here:
http://ahkscript.org/boards/viewtopic.p ... 635#p45635
where I try to use GuiSize to size one edit control but not the other and vice versa.
toralf
Posts: 868
Joined: 27 Apr 2014, 21:08
Location: Germany

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

16 May 2015, 11:25

Try to use the version which has the options as the first parameter and then a variadic list of controls.
ciao
toralf
User avatar
BGM
Posts: 507
Joined: 20 Nov 2013, 20:56
Contact:

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

16 May 2015, 11:37

toralf - that's the autoxywh.ahk (not anchor)

; Release date: 2014-7-03
; Author : tmplinshi (mod by toralf)
; requires AHK version : 1.1.13.01+

I've played around with this for some time now (I've tried both versions of AutoXYWH). It looks like I'm going to have to do all the math myself.
AutoXYWH, for some reason, just doesn't seem to respect the settings - it's as if it conflicts with itself.

So I tried reversing things. In the following configuration, when you hold shift, none of the boxes resize at all.
It seems like autoxywh is ignoring the second declaration.
Further, if you shift+resize and then try to resize without shift, autoxywh doesn't respect the new size of the box.

Code: Select all

	isdown := getkeystate("shift","P")
	if(isdown){
		autoxywh("w", "edit2")
	}else{
		autoxywh("x*", "edit2")
		autoxywh("w", "edit1")	
	}
toralf
Posts: 868
Joined: 27 Apr 2014, 21:08
Location: Germany

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

16 May 2015, 22:46

It stores the initial control size and position relative to the GUI size. All further movements are depending on the new GUI size. You are right you can not switch between different options nor can you reset the initial size/position.
ciao
toralf
m3user
Posts: 235
Joined: 17 Jan 2014, 18:11

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

21 May 2015, 05:12

Thank you very much tmplinshi for adding a reset option. I tried it with my basic example (below) and it works well. You should update the function on the first page, maybe you could consider using a simpler parameter like AutoXYWH("r")or even AutoXYWH().

Code: Select all

Gui, +Resize
Gui, Add, Edit, ve1 w150 h100
Gui, Add, Button, vb1 gResize, Resize
Gui, Show		
return

Resize:
GuiControl, Move, e1, h50
AutoXYWH("update_ctrl_info")
return

GuiSize:
AutoXYWH("wh", "e1")		
AutoXYWH("y", "b1")		
return
tmplinshi
Posts: 1604
Joined: 01 Oct 2013, 14:57

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

28 May 2015, 20:32

I added a note about the 'reset' option to the first post.

Added the reset option, and changed the version info to:

Code: Select all

; Version: 2015-5-29 / Added 'reset' option (by tmplinshi)
;          2014-7-03 / toralf
;          2014-1-2  / tmplinshi

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 110 guests