AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Two built-in variables should change behavior...

 
Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
kapege.de



Joined: 07 Feb 2005
Posts: 192
Location: Munich, Germany

PostPosted: Mon Aug 31, 2009 2:18 pm    Post subject: Two built-in variables should change behavior... Reply with quote

I found a nasty itch that would be great to heal: The vars A_GuiWidth and A_GuiHeight are only valid within the GuiSize subroutine. Why not always?
To fit a Tab within a GUI afterwards I has to do that following "construct" to outsmart it (working sample):
Code:
gui, add, Tab2, h30,Tab1|Tab2|Tab3
loop, 10
    gui, add, Button,, Button%A_Index%
gui, show
sleep, 500
msgbox, %mHeight% ; This is only for demonstration. Remove the Sleep command and watch the difference.
; The following line works, because due to the time lapse of the MsgBox command the subroutine had have enough time to fetch the height.
GuiControl, Move, SysTabControl321, % "h" mHeight + 25
Return

GuiSize:
mHeight = %A_GuiWidth%
Return

GuiEscape:
ExitApp


Especially the Sleep command is neccessary! W/o it the next command (MsgBox) is executed before the subroutine can fetch the value for the height!

Please make the vars A_GuiWidth and A_GuiHeight permanent. Also a pair for the upper left corner of the GUI would be great (A_GuiX an Y are sorrily preoccupied).

Many thanks in advance!
_________________
Peter

Wisenheiming for beginners: KaPeGe (German only, sorry)
Back to top
View user's profile Send private message Visit poster's website
TheIrishThug



Joined: 19 Mar 2006
Posts: 419

PostPosted: Mon Aug 31, 2009 2:45 pm    Post subject: Reply with quote

The problem with doing that is how do you decide what value A_GuiHeight has when you have more than one GUI?

As an alternative, you could use WinGetPos to get the window size. Another option is to plan out the GUI ahead of time and do all the calculation before you call GUI show (and then set the size in the command).
Back to top
View user's profile Send private message Visit poster's website AIM Address
kapege.de



Joined: 07 Feb 2005
Posts: 192
Location: Munich, Germany

PostPosted: Mon Aug 31, 2009 4:28 pm    Post subject: Reply with quote

Thanks for your hints, mate!
TheIrishThug wrote:
The problem with doing that is how do you decide what value A_GuiHeight has when you have more than one GUI?
It's value changes with the active GUI. Wink
TheIrishThug wrote:

As an alternative, you could use WinGetPos to get the window size. Another option is to plan out the GUI ahead of time and do all the calculation before you call GUI show (and then set the size in the command).

That calculation-thing is much too difficult. And what if I wish to change the fontsize etc.? Actually I've 225 automatically generated Buttons spread over four tabs (keywords to index pictures in ThumbsPlus). Shocked

The solution was the WinGetPos command: I tried it before but it gave always the whole screensize back and not the size of my window, so I tried other solutions and found that "non-working" A_GuiHeight".
What I did wrong was, that I thought, that the "Gui, show" followed by a WinGetPos w/o a WinTitle uses the Last Found Window, but it didn't. After I wrote down the window name it works.

Many thanks for that unexpected solution! But nevertheless: a always active A_GuiWidth/Height variable would be great.
_________________
Peter

Wisenheiming for beginners: KaPeGe (German only, sorry)
Back to top
View user's profile Send private message Visit poster's website
Guessed
Guest





PostPosted: Tue Sep 01, 2009 6:06 am    Post subject: Reply with quote

It's a good point. AutoHotkey already has features which use the "default" GUI; GUI subroutines such as GuiSize set it, as does this:
Code:
Gui, 2:Default

A_GuiWidth/Height should just get the size of the default GUI.
Back to top
Lexikos



Joined: 17 Oct 2006
Posts: 7293
Location: Australia

PostPosted: Tue Sep 01, 2009 8:11 am    Post subject: Reply with quote

kapege.de wrote:
What I did wrong was, that I thought, that the "Gui, show" followed by a WinGetPos w/o a WinTitle uses the Last Found Window, but it didn't.
Gui Show does not change the Last Found Window; Gui +LastFound does.

Here's an alternative to WinGetPos which should be equivalent to A_GuiWidth/Height:
Code:
Gui, Show, w500 h400 Hide
GetGuiSize(GuiWidth, GuiHeight)
Sleep 500 ; Delay for GuiSize.
MsgBox % "GetGuiSize: " GuiWidth "x" GuiHeight "`nGuiSize: " GuiWidth2 "x" GuiHeight2
ExitApp

GuiSize:
GuiWidth2 := A_GuiWidth
GuiHeight2 := A_GuiHeight
return


GetGuiSize(ByRef w, ByRef h, n="") {
    if n !=
        n = %n%:
    Gui, %n%+LastFoundExist
    ifWinNotExist
        return w := h := ""
    VarSetCapacity(rect, 16)
    DllCall("GetClientRect", "uint", WinExist(), "uint", &rect)
    w := NumGet(rect, 8)
    h := NumGet(rect, 12)
}
You may optionally specify the GUI number as the third parameter. If omitted, the current default GUI is used.
Back to top
View user's profile Send private message Visit poster's website
kapege.de



Joined: 07 Feb 2005
Posts: 192
Location: Munich, Germany

PostPosted: Tue Sep 01, 2009 2:47 pm    Post subject: Reply with quote

Thank you, master! Wink
You did it very well. But that amount of code let me yell for a simple solution in the next AHK-version for a plain working A_GuiWidth/Height.

...

Chris, please!
_________________
Peter

Wisenheiming for beginners: KaPeGe (German only, sorry)
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Wish List All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group