Sign in to follow this  
Followers 0
SteveJM

Can't see picture in a group box

5 posts in this topic

I'm writing a GUI which mimics a control panel to look after a piece of hardware. I have some small GIF images that look similar to an LED which can be off, green amber etc. I have used GUICtrlCreatePic() to put them in and GUICtrlSetImage() to change the display. That much works fine.

There are quite a few controls and I thought I would group them into group boxes using GUICtrlCreateGroup(). I have been using Koda, which seemed to imply this was ok (it's used in the help about template for example), but it doesn't seem to work. Is this a bug or is my intention simply misconceived? Here is some example code. Note that one picture is in the group box and one outside it, just to cover possible errors in the picture file. The picture outside the group displays ok but not the one inside.

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=test.kxf
$Form2 = GUICreate("Form2", 212, 128, 191, 115)
$Group1 = GUICtrlCreateGroup("Group1", 16, 16, 97, 89)
$Pic1 = GUICtrlCreatePic("Graphics\on.gif", 32, 40, 24, 24, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Label1 = GUICtrlCreateLabel("Label1", 32, 72, 36, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Pic2 = GUICtrlCreatePic("Graphics\on.gif", 128, 40, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

I can work around it by using graphics objects I guess and make something that looks similar, but it would be easier to deal with them in groups. So have I just missed something blindingly obvious? (apologies if I have)

Thanks for any advice

Share this post


Link to post
Share on other sites



Sorry, I should probably have mentioned that I'm using Autoit 3.3.6.1 under Windows XP.

Share this post


Link to post
Share on other sites

SteveJM,

It is a problem with the order that Windows uses for displaying picture controls - it seems to place them in the layer it wants, regardless of where you create them in the script. I often have trouble getting them in the right order if I have to overlap several of Pic controls.

The solution to your problem is to create the Group control AFTER the picture - that way it does not cover the picture which was there all the time: ;)

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=test.kxf
$Form2 = GUICreate("Form2", 212, 128, 191, 115)
$Pic1 = GUICtrlCreatePic("Graphics\on.gif", 32, 40, 24, 24, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Group1 = GUICtrlCreateGroup("Group1", 16, 16, 97, 89)
$Label1 = GUICtrlCreateLabel("Label1", 32, 72, 36, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Pic2 = GUICtrlCreatePic("Graphics\on.gif", 128, 40, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

That works fine for me. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

or clipsiblings on the group rather than the picture

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=test.kxf
$Form2 = GUICreate("Form2", 212, 128, 191, 115)
$Group1 = GUICtrlCreateGroup("Group1", 16, 16, 97, 89, $WS_CLIPSIBLINGS)
$Pic1 = GUICtrlCreatePic("AFF.jpg", 32, 40, 24, 24, Bitor ($SS_NOTIFY, $WS_GROUP))
$Label1 = GUICtrlCreateLabel("Label1", 32, 72, 36, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Pic2 = GUICtrlCreatePic("AFF.jpg", 128, 40, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd

Exit

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Thanks guys. I really did think I'd tried everything, but clearly not. Both suggestions are very helpful.

I'd messed with the WS_CLIPSIBLINGS before, but had not tried the combination ticked for the group box and unticked for the pic.

Because I find Koda so useful, and its fast update of the Autoit code, I was trying to find a solution that allowed me to keep using it. If anyone else is reading this, there seems to be a Koda (1.7.2.0 & 1.7.3.0) snag with pics inside a group box. I was delightedly trying out iamthek's solution, seeing it work BUT having saved the Koda file and then reloaded it, the pictures were all greyed out in the Koda edit view. The run form preview still works and you can see where the pictures will be as dotted lines.

Melba23's solution also worked for me - in Koda you use the 'Edit tab order' to get the Group box created last in the generated Autoit code.

Now I can get on with the real work, so once again thanks for the quick replies.

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