Jump to content

Button Images


Recommended Posts

Hey everyone,

I am new to building GUI's, having only done it with Excel/VBA. Anyway, the graphic design like elements are very important to me, so before I dive into the meat of it, I am trying to see if I can even use AutoIt to design to a standard I am happy with.

What I am trying to do now is replace the standard look of a button with an image. While I feel this should be very simple, I cannot get it to work. Here is my code so far: 

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

$Form1 = GUICreate("LogIn", 615, 441, -1, -1)

$Button1 = GUICtrlCreateButton("Button1", 80, 80, 196, 45)
GUICtrlSetImage(-1, "G:\Eric\LoginGUITesting\Button.jpg")

GUISetBkColor(0x444444)

GUISetState(@SW_SHOW)

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

    EndSwitch
WEnd

I've been reading through all the topics I can find on this, but I cannot seem to get it. This thread by @david1337 is the general idea of what I am trying to accomplish.

 


Thanks in advance everyone,

Eric

Link to comment
Share on other sites

$Button1 = GUICtrlCreateButton("Button1", 80, 80, 196, 45, $BS_BITMAP)

You'll need to use bmp files. If you want to use any file type you'll have to load the file into memory first (using GDI+ makes it extremely easy) and then use

_WinAPI_DeleteObject(GUICtrlSendMsg(ID OF CONTROL, $STM_SETIMAGE, $IMAGE_BITMAP, HANDLE TO THE HBITMAP OBJECT))

To set the button image

Link to comment
Share on other sites

Thanks for the reply, @InunoTaishou.

Even when I do try and use the .bmp images, it still does not work.

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

$Form1 = GUICreate("LogIn", 615, 441, -1, -1)

$Button1 = GUICtrlCreateButton("Button 1", 80, 80, 196, 45, $BS_BITMAP)
GUICtrlSetImage(-1, "G:\Eric\LoginGUITesting\button.bmp")

GUISetBkColor(0x444444)

GUISetState(@SW_SHOW)

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

    EndSwitch
WEnd

I am really scratching my head on this one... :blink:

Edited by ericbartha
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...