ericbartha Posted March 22, 2016 Share Posted March 22, 2016 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 More sharing options...
ericbartha Posted March 22, 2016 Author Share Posted March 22, 2016 Please note I have also tried using a .png and a .bmp with which I modified the GUICtrlSetImage function to include "$BS_BITMAP, as David1337 did in his example. Link to comment Share on other sites More sharing options...
InunoTaishou Posted March 22, 2016 Share Posted March 22, 2016 $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 More sharing options...
ericbartha Posted March 22, 2016 Author Share Posted March 22, 2016 (edited) 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... Edited March 22, 2016 by ericbartha Link to comment Share on other sites More sharing options...
InunoTaishou Posted March 22, 2016 Share Posted March 22, 2016 I don't have your bmp file so I can't test it Link to comment Share on other sites More sharing options...
ericbartha Posted March 22, 2016 Author Share Posted March 22, 2016 Ha - got it, thanks! I wasn't thinking to check the file itself.... While rushing, I just renamed the extension instead of actually saving the file properly as a .bmp. For obvious reasons, this was my issue. Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now