Sign in to follow this  
Followers 0
John

Shouldn't GUICreate (width,height) be window not client?

3 posts in this topic

I usually don't try to polish GUIs for end users but I ran into this:

#include <WindowsConstants.au3>
Opt("GUIOnEventMode",1)
Dim $GUI, $Gpos, $ini=@ScriptDir&"\conf.ini"
$Gpos=StringSplit(IniRead($ini,"settings","GIUmetrics","-1:-1:-1:-1:0"),":",2)
$GUI=GUICreate("Reference Managment",$Gpos[0],$Gpos[1],$Gpos[2],$Gpos[3],BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_SIZEBOX))
GUISetOnEvent(-3, "Xit")
GUISetState()
Sleep(2147483647)

Func Xit()
Local $s=WinGetPos("Reference Managment")
IniWrite($ini,"settings","GIUmetrics",$s[2]&":"&$s[3]&":"&$s[0]&":"&$s[1])
Exit
EndFunc

What happens is the window width grows by 16 and the height by 38 each time it is reopened. Testing shows that the width and height parameters of GUICreate() are using client area metrics. Hence WinGetPos() and WinGetClientSize() must both be called and the results recombined to get any useful state metrics. Yet the help files defines the height parameter as "The height of the window", as it does the width.

Share this post


Link to post
Share on other sites



If it was window then you wouldn't know what size the client area would be, and that is what matters when you create the GUI. How else would you place your controls?

Sure, you could do a bunch of math on every coordinate, but why would you want that when the current way only needs some basic addition at exit. Much simpler.

Share this post


Link to post
Share on other sites

So basically it is either do it on the front end or back end. Now that I think about it actually creating a specific window size with an unknown window style would be quiet a feat. Not to mention creating other more serious issues for users trying to code. So the only real point is that the help file language didn't reflect what it actually does.

I wouldn't mind deprecating WinGetClientSize() and simply upgrade WinGetPos() with an optional arg to determine which width/height parameter you wanted. It could likely clean out more bytes than what it consumes.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0