Jump to content
Sign in to follow this  
ludocus

image as button?

Recommended Posts

ludocus

is there a way to put an image in your gui as a button?

Share this post


Link to post
Share on other sites
ProgAndy

If it needen't look like a Button with a pushed state, just add $SS_NOTIFY in the normal Style


*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites
Swift

Well If: GUICtrlCreatePic() Is what you want, then you can use hover udf, to change it's appearance like a button.

Share this post


Link to post
Share on other sites
Tvern

is there a way to put an image in your gui as a button?

I was just trying to do the same thing. Make a 100x100 pixel image call a function when clicked.

$Button = GUICtrlCreateButton ("", 10,-1,100,100,$BS_BITMAP)
GUICtrlSetImage(-1,"Path\image.bmp")oÝ÷ ØƤzƺÛh­©â¨¢{h¦âµ»­×åÉÊ'µ¨§nj_W¬jëh×6$Button = GUICtrlCreateButton ("", 10,-1,100,100,$BS_ICON)
GUICtrlSetImage(-1,"Path\icon.ico")

Does the same, but only accepts *.ico and libraries containing them.

I am still trying to find a way to make clicking a jpg call a function, but it might not be possible.

Edit:

But then the $SS_NOTIFY seems pretty much exactly what I need. :D I make stuff way to complicated some times.

Adding a different cursor style on mouseover will make it more intuitive in use aswell.

Edited by Tvern

Share this post


Link to post
Share on other sites
James

#include <GUIConstants.au3>

GUICreate("Image button", 95, 55)
$Button = GUICtrlCreateButton("", 10, 10, 75, 35, $BS_ICON)
GUICtrlSetImage(-1, "shell32.dll", 10)

GUISetState()

While 1
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button
            MsgBox(0, "", "You clicked the icon button!")
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites
Valuater

#include <GUIConstants.au3>
 
 GUICreate("Image button", 95, 55)
 $Button = GUICtrlCreateButton("", 10, 10, 75, 35, $BS_ICON)
 GUICtrlSetImage(-1, "shell32.dll", 10)
 
 GUISetState()
 
 While 1
     $iMsg = GUIGetMsg()
     Switch $iMsg
         Case $GUI_EVENT_CLOSE
             Exit
         Case $Button
             MsgBox(0, "", "You clicked the icon button!")
     EndSwitch
 WEnd
Maybe, you can try reading this again

...

$Button = GUICtrlCreateButton ("", 10,-1,100,100,$BS_ICON)
GUICtrlSetImage(-1,"Path\icon.ico")

Does the same, but only accepts *.ico and libraries containing them.

I am still trying to find a way to make clicking a jpg call a function, but it might not be possible.

8


NEWHeader1.png

Share this post


Link to post
Share on other sites
NELyon

#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
$hGUI = GUICreate("Test", 300, 300)
$pic = GUICtrlCreatePic("Path.To.jpg", 0, 0, -1, -1, $SS_NOTIFY)
GUISetState()
While 1
    Switch GUIGetMsg()
        Case -3 
            Exit
        Case $pic
            MsgBox(0, "Hmm", "MMkay?")
    EndSwitch
WEnd

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.