Jump to content
Sign in to follow this  
Spiff59

GUICtrlCreateGroup() question.

Recommended Posts

Spiff59

Why would the following three groups all have different "top" and "height" coordinates?

$GUI_Main = GuiCreate("", 480, 280)
GUISetState(@SW_SHOW, $GUI_Main)

$len = 360
Display_Group()
Sleep(1000)
GUISetFont(14)
$len = 320
Display_Group()
Sleep(1000)
GUISetFont(6)
$len = 280
Display_Group()

While 1
    $msg = GUIGetMsg()
    If $msg = -3 Then   ExitLoop
Wend
Exit

;-------------------------------------------------------------------------------
Func Display_Group()
    GUICtrlCreateGroup("", 20, 80, $len, 90)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
EndFunc

Is it normal behavior for the current font size to affect both the location and size of group controls?

Edit: Answering my own question: I didn't think so...

Edited by Spiff59

Share this post


Link to post
Share on other sites
therks

I hadn't noticed this before, but it does sort of make sense. If you put some text in the first param of that GUICtrlCreateGroup you'll see that it always tries to match up that top edge with the middle of the text. So when the text changes size, so does the position of the top edge. I can see what MS had in mind when they set that up, but I can also see where that can make things confusing.

Share this post


Link to post
Share on other sites
Tankbuster

First it looks very funny and strange, but as I played a little with your code I found out that the second frame always was out of place. So I added a text and found that the font of the caption was different. So I added in the Display_Group the GUICtrlSetFont(-1,10).

Now the groups are in the same possition. Does this help you?

(to see the difference just remark my line GUICtrlSetFont(-1,10)....

#include <WindowsConstants.au3>
$GUI_Main = GuiCreate("", 480, 280)
GUISetState(@SW_SHOW, $GUI_Main)

$len = 50
Display_Group(1)
Sleep(1000)
GUISetFont(14)
$len = 100
Display_Group(2)
Sleep(1000)
GUISetFont(6)
$len = 150
Display_Group(3)

While 1
    $msg = GUIGetMsg()
    If $msg = -3 Then   ExitLoop
Wend
Exit

;-------------------------------------------------------------------------------
Func Display_Group($i)
    GUICtrlCreateGroup($i, 20, 10, $len, 100,-1,-1)
    GUICtrlSetFont(-1,10)
;~     GUICtrlCreateGroup("", -99, -99, 1, 1)
EndFunc

Share this post


Link to post
Share on other sites
therks

So I added a text and found that the font of the caption was different. So I added in the Display_Group the GUICtrlSetFont(-1,10).

I think that was his point actually. He was wondering why the font size was affecting the group's appearance, hence his comment:

Is it normal behavior for the current font size to affect both the location and size of group controls?

Share this post


Link to post
Share on other sites
Tankbuster

@therks

Sorry, my fault. It looks like he was searching for a solution.

Share this post


Link to post
Share on other sites
therks

Yeah and to me it doesn't look like there is one, short of doing something like you did. I think that would just be the best option. Wrap GUICtrlCreateGroup in a function like yours and go to town.

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  

×