Jump to content

Pics defined within group are incorrect


van_renier
 Share

Recommended Posts

Please help me here on this. I may just be having a syntax, or ordering issue, but trying to have some bitmaps displayed for status indicators are giving problems;

1. If the GuiCtrlCreatePic() is defined within a GuiCtrlCreateGroup() parameters, the width/height of the Pic is not adhered to.

2. If the Pic is defined outside (before or after) the GuiCtrlCreateGroup() parameters, then the Pic displays using the width/height arguments.

Please take a look at the script below and help me find out why.

Thanks for your time and assistance,

Van

--I have found that;

1. Resizing the window will 'correct' the sizes of the images, but modifying them with "GUICtrlSetImage()" require another window resize to correct.

2. Resizing the window will scale move the Pics, but using the "GUICtrlSetImage()" will update the PIc at its original location, not the now window-resized location.

#include <GuiConstants.au3>
If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000
GuiCreate("MyGUI", 640, 380,(@DesktopWidth-640)/2, (@DesktopHeight-380)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$GUIGroup_1 = GuiCtrlCreateGroup("Pic definied within Group", 10, 10, 200, 100)
$GUILabel_STATUS_1 = GuiCtrlCreatePic("Light_Red_Off.bmp", 50, 50, 15, 15)
GUICtrlCreateGroup ("",-99,-99,1,1);close group
; ##############################
$GUILabel_STATUS_2 = GuiCtrlCreatePic("Light_Red_Off.bmp", 50, 250, 15, 15)
$GUIGroup_2 = GuiCtrlCreateGroup("Pic defined OUTSIDE Group", 10, 200, 200, 100)
GUICtrlCreateGroup ("",-99,-99,1,1);close group

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
          ;;;
    EndSelect
    sleep ( 15 )
WEnd
Exit

Light_Red_Off.bmp

Edited by van_renier
Link to comment
Share on other sites

Interesting phenomenom. However, I believe groups are made for radio buttons so that could explain why your pictures look strange. In fact, when I increase the size of your bitmaps, it show TWO bitmaps... one that is normal size and one that you can resize. The resized one appears to be behind the normal one.

Anyway, is there a reason you want to put them into groups, or are you just testing? You could just create a bitmap with borders around the button if it is borders you want. Or, as you have already found out, just put the bitmaps outside the group.

Nevertheless, that definitely piqued my interest and got me playing around with your script for a while to see what kinds of things I could make it do (and not do).

Thanks for sharing.

Link to comment
Share on other sites

Interesting phenomenom. However, I believe groups are made for radio buttons so that could explain why your pictures look strange. In fact, when I increase the size of your bitmaps, it show TWO bitmaps... one that is normal size and one that you can resize. The resized one appears to be behind the normal one.

Anyway, is there a reason you want to put them into groups, or are you just testing? You could just create a bitmap with borders around the button if it is borders you want. Or, as you have already found out, just put the bitmaps outside the group.

Nevertheless, that definitely piqued my interest and got me playing around with your script for a while to see what kinds of things I could make it do (and not do).

Thanks for sharing.

<{POST_SNAPBACK}>

"...I believe groups are made for radio buttons" and "...is there a reason you want to put them into groups"

I want subdividers (boxes/lines) making it easier for the users to see which controls belong together,similar to the below screenshot for system properties.

Van

SystemProperties.bmp

Link to comment
Share on other sites

"...I believe groups are made for radio buttons" and "...is there a reason you want to put them into groups"

I want subdividers (boxes/lines) making it easier for the users to see which controls belong together,similar to the below screenshot for system properties.

Van

SystemProperties.bmp

<{POST_SNAPBACK}>

Well, since you are going for aesthetics and not functionality (as would be the case if you were using radio buttons) putting the bitmaps outside the group would be the best bet... and likely any command buttons. However, I am sure you have already come to this conclusion. I just like to hear myself type. :whistle:
Link to comment
Share on other sites

Funny, the size of the bmp depends on when it is put outside the Group control.

The left on is drawn before the Group control, the right one after the group control.

Don't know why. Just an observation.

#include <GuiConstants.au3>
;If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000
GuiCreate("MyGUI", 640, 380,(@DesktopWidth-640)/2, (@DesktopHeight-380)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$GUIGroup_1 = GuiCtrlCreateGroup("Pic definied within Group", 10, 10, 200, 100)
$GUILabel_STATUS_1 = GuiCtrlCreatePic("Light_Red_Off.bmp", 50, 50, 15, 15)
GUICtrlCreateGroup ("",-99,-99,1,1);close group
; ##############################
$GUILabel_STATUS_2 = GuiCtrlCreatePic("Light_Red_Off.bmp", 50, 250, 15, 15); Before Group control
$GUIGroup_2 = GuiCtrlCreateGroup("Pics defined OUTSIDE Group", 10, 200, 200, 100)
GUICtrlCreateGroup ("",-99,-99,1,1);close group
$GUILabel_STATUS_3 = GuiCtrlCreatePic("Light_Red_Off.bmp", 100, 250, 15, 15); After Group control

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
         ;;;
    EndSelect
    sleep ( 15 )
WEnd
Exit
Link to comment
Share on other sites

Well, since you are going for aesthetics and not functionality (as would be the case if you were using radio buttons) putting the bitmaps outside the group would be the best bet... and likely any command buttons. However, I am sure you have already come to this conclusion. I just like to hear myself type. :whistle:

<{POST_SNAPBACK}>

I'm not looking to have the users click the bitmaps. I just want a visual display of the status/condition. Is there a better method for doing this? (as opposed to usign the GUICtrlCreatePic() )

(If I presented the full GUI you'd see what I was doing, but I'm sure that would detered from getting responses, as iti's quite complex.)

Van

Link to comment
Share on other sites

Funny, the size of the bmp depends on when it is put outside the Group control.

The left on is drawn before the Group control, the right one after the group control.

Don't know why. Just an observation.

<{POST_SNAPBACK}>

Yeah... I added in some pauses after it sets the GUI state, showing the order/process of the control creations.

(the names of the lights/bitmaps have changed snce my original post, and reflected in the below code)

I just find it odd that if the Pic is defined within a group, it's width and height are not considered (until after a resize, then it'll refresh properly).

#include <GuiConstants.au3>
;If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000
GuiCreate("MyGUI", 640, 380,(@DesktopWidth-640)/2, (@DesktopHeight-380)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

GuiSetState()
sleep ( 1500 )
$GUIGroup_1 = GuiCtrlCreateGroup("Pic definied within Group", 10, 10, 200, 100)
sleep ( 1500 )
$GUILabel_STATUS_1 = GuiCtrlCreatePic( ".\DATA\Red0.bmp", 50, 50, 15, 15)
sleep ( 1500 )
GUICtrlCreateGroup ("",-99,-99,1,1);close group
sleep ( 1500 )
; ##############################
sleep ( 1500 )
$GUILabel_STATUS_2 = GuiCtrlCreatePic(".\DATA\YEllow0.bmp", 50, 250, 15, 15); Before Group control
sleep ( 1500 )
$GUIGroup_2 = GuiCtrlCreateGroup("Pics defined OUTSIDE Group", 10, 200, 200, 100)
sleep ( 1500 )
GUICtrlCreateGroup ("",-99,-99,1,1);close group
sleep ( 1500 )
$GUILabel_STATUS_3 = GuiCtrlCreatePic(".\DATA\Green0.bmp", 100, 250, 15, 15); After Group control
sleep ( 1500 )

While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
        ;;;
    EndSelect
    sleep ( 15 )
WEnd
Exit
Link to comment
Share on other sites

@Van: it's a refreshing bug in the current (beta) version.

I  found a solution and will give this info to jpm :whistle:

Regards

Holger

<{POST_SNAPBACK}>

Thanks, Holger.

Appreciate the support.

(Ironic.... All the times I thought 'they' were bugs and they turned out being operator-error. The one time I think I'm doing it wrong, and it IS bug.)

Van

Link to comment
Share on other sites

It's solved in the new current beta 3.1.1.73...

But however: a question: what does the line mean?:

GUICtrlCreateGroup ("",-99,-99,1,1);close group

I see no reason wh it must be in - maybe one explain me please.

Thanks and regards :whistle:

Holger

Link to comment
Share on other sites

It's solved in the new current beta 3.1.1.73...

But however: a question: what does the line mean?:

GUICtrlCreateGroup ("",-99,-99,1,1);close group

I see no reason wh it must be in - maybe one explain me please.

Thanks and regards :whistle:

Holger

<{POST_SNAPBACK}>

I think it would be better to ask whoever wrote it in the Help File:

#include <GUIConstants.au3>

GUICreate("My GUI group") ; will create a dialog box that when displayed is centered

GUICtrlCreateGroup ("Group 1", 190, 60, 90, 140)
$radio_1 = GUICtrlCreateRadio ("Radio 1", 210, 90, 50, 20)
$radio_2 = GUICtrlCreateRadio ("Radio 2", 210, 110, 60, 50)
GUICtrlCreateGroup ("",-99,-99,1,1) ;close group

GUISetState ()    ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...