Sign in to follow this  
Followers 0
suthern101

Images on Buttons. Broken?

2 posts in this topic

I can't seem to load an image onto a button. Are there special requirements for the size or type that are different than for GUICtrlCreatePic?

Here's the code with a button which SHOULD have an image on it. GUICtrlCreatePic works fine. I've tried JPG,BMP,GIF with the button. No luck yet. Any ideas?

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>

$pic_path = "path/to/image"

$hGUI = GUICreate("Test", 400, 500)

$hPic = GUICtrlCreatePic($pic_path, 10, 10, 380, 380)

$hButton = GUICtrlCreateButton("Boo", 10, 400, 80, 80, $BS_BITMAP)
GUICtrlSetImage($hButton, $pic_path)

GUISetState()

While 1
 
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hPic
            MsgBox(0, "Hi!", "You clicked the picture")
        Case $hButton
            MsgBox(0, "Hi!", "You clicked the button")
    EndSwitch

WEnd

Share this post


Link to post
Share on other sites



Ahh, it works with BMP files. I wonder if this could be added to the help file, possibly in the GUICtrlCreateButton page? or a note on GUICtrlSetImage.

This topic can now be closed, but may be handy as future reference to other newcomers who stumble at the same thing.

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