Jump to content

image as button?


Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

#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

Link to comment
Share on other sites

#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

Link to comment
Share on other sites

#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

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...