Datus Posted August 30, 2008 Share Posted August 30, 2008 Been using Autoit for some time and used pictures as buttons, buttons as buttons with text but id like to have a button with a background picture with text.Can someone confirm this cant be done still or example small code.$LoadIsoPickedNo = GUICtrlCreateButton("Pick another", $AdjustW - (180 * $MultiW), $AdjustH - 35, (95 * $MultiW), 27, $BS_BITMAP) GUICtrlSetImage($LoadIsoPickedNo, @WorkingDir & "\button.bmp")with the above i dont see the text Pick anotherspent several hours looking in help and forum which both is very good source.i think the only sugestion ive seen is to create a bitmap with the text on it. We live as we dream alone! Link to comment Share on other sites More sharing options...
Valuater Posted August 30, 2008 Share Posted August 30, 2008 I made this...; Icon on Button - (made easy) ; Author - Valuater #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $mywin = GUICreate("my gui") $btn1 = IconButton("Help", 30, 30, 70, 32, 23) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $btn1 Then MsgBox(0,0,"You pressed the Icon Button ", 2) If $msg = $GUI_EVENT_CLOSE Then Exit WEnd Func IconButton($BItext, $BIleft, $BItop, $BIwidth, $BIheight, $BIconNum, $BIDLL = "shell32.dll") GUICtrlCreateIcon($BIDLL, $BIconNum, $BIleft + 5, $BItop + (($BIheight - 16) / 2), 16, 16) GUICtrlSetState( -1, $GUI_DISABLE) $XS_btnx = GUICtrlCreateButton($BItext, $BIleft, $BItop, $BIwidth, $BIheight, $WS_CLIPSIBLINGS) Return $XS_btnx EndFuncMaybe it can help you... there are more "helpers" herehttp://www.autoitscript.com/forum/index.ph...st&p=1337698) Link to comment Share on other sites More sharing options...
Datus Posted August 30, 2008 Author Share Posted August 30, 2008 Valuater ive seen that and yes it was handy but its for icons. hmm You saying save the bmp as an icon? If so will the text go over the top of the icon? We live as we dream alone! Link to comment Share on other sites More sharing options...
rover Posted August 31, 2008 Share Posted August 31, 2008 (edited) Valuater ive seen that and yes it was handy but its for icons. hmm You saying save the bmp as an icon? If so will the text go over the top of the icon?@Datus Text will go over the bitmap with this example, but XP is the minimum OS. expandcollapse popup;#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GUIConstantsEx.au3> #include <GuiButton.au3> #include <GuiImageList.au3> Opt("MustDeclareVars", 1) _Main() Func _Main() Local $sBMPNormal = @WindowsDir & "\pchealth\helpctr\System\images\24x24\arrow_green_normal.bmp" Local $sBMPHot = @WindowsDir & "\pchealth\helpctr\System\images\24x24\arrow_green_mouseover.bmp" Local $sBMPPress = @WindowsDir & "\pchealth\helpctr\System\images\24x24\arrow_green_mousedown.bmp" Local $sBMPImage = @WindowsDir & "\pchealth\helpctr\System\blurbs\watermark_300x.bmp" Local $btn1, $btn2, $btn3, $btn4, $msg Local $hImagebtn1, $hImagebtn2, $hImagebtn3 ,$hImagebtn4 ;Caveat: Minimum Operating Systems: Windows XP. ;Image list with multiple images will only show the images ;other than the 1st image when Themes are used. Local $hGUI = GUICreate("Button Imagelists - Minimum OS: Windows XP",400,300) GUICtrlCreatePic(@WindowsDir & "\Web\Wallpaper\Windows XP.jpg", 0, 0, 400, 300) GUICtrlSetState(-1, $GUI_DISABLE) ;multi state image Bitmap $btn1 = GUICtrlCreateButton("This Way", 30, 30, 90, 32) GUICtrlSetTip(-1, "Multi state bitmap imagelist") $hImagebtn1 = _GUIImageList_Create(24, 24, 5, 5) _GUIImageList_AddBitmap($hImagebtn1, $sBMPNormal);1 - Normal _GUIImageList_AddBitmap($hImagebtn1, $sBMPHot) ;2 - Hot _GUIImageList_AddBitmap($hImagebtn1, $sBMPPress) ;3 - Pressed _GUIImageList_AddBitmap($hImagebtn1, $sBMPPress);4 - Disabled _GUIImageList_AddBitmap($hImagebtn1, $sBMPNormal);5 - Defaulted _GUIImageList_AddBitmap($hImagebtn1, $sBMPNormal);6 - Stylus Hot (tablet computers only) _GUICtrlButton_SetImageList($btn1, $hImagebtn1) ;single state image Bitmap $btn2 = GUICtrlCreateButton("This Way", 30, 70, 90, 32) GUICtrlSetTip(-1, "Single bitmap imagelist") $hImagebtn2 = _GUIImageList_Create(24, 24, 5, 3) _GUIImageList_AddBitmap($hImagebtn2, $sBMPNormal);1 - Normal _GUICtrlButton_SetImageList($btn2, $hImagebtn2) ;single state image Icon $btn3 = GUICtrlCreateButton("Unlock", 30, 110, 90, 40) GUICtrlSetTip(-1, "Single icon imagelist") $hImagebtn3 = _GUIImageList_Create(32, 32, 5, 3) _GUIImageList_AddIcon($hImagebtn3, "shell32.dll", 47, True) _GUICtrlButton_SetImageList($btn3, $hImagebtn3) ;single state image Bitmap with overlayed text $btn4 = GUICtrlCreateButton("Help", 30, 160, 90, 90) GUICtrlSetTip(-1, "Single bitmap imagelist with overlayed text") GUICtrlSetFont(-1, 14, 800, -1, "Comic Sans MS") $hImagebtn4 = _GUIImageList_Create(80, 80, 5, 3) _GUIImageList_AddBitmap($hImagebtn4, $sBMPImage) _GUICtrlButton_SetImageList($btn4, $hImagebtn4, 4) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $btn1 Case $btn2 GUICtrlSetState($btn1, $GUI_DISABLE) Case $btn3 GUICtrlSetState($btn1, $GUI_ENABLE) Case $btn4 EndSwitch WEnd EndFunc ;==>_Main Edited August 31, 2008 by rover I see fascists... Link to comment Share on other sites More sharing options...
Valuater Posted August 31, 2008 Share Posted August 31, 2008 Nice example rover!!! 8) Link to comment Share on other sites More sharing options...
Datus Posted August 31, 2008 Author Share Posted August 31, 2008 interesting, im looking at it now. will get back to you. We live as we dream alone! Link to comment Share on other sites More sharing options...
Datus Posted August 31, 2008 Author Share Posted August 31, 2008 Brilliant,Got it working with some bitmaps i had lying arround.Cant see why i didnt see the _GUICtrlButton_SetImageList etc before.Fairly easy concept.Thanks again rover and im sure this thread will help many others. We live as we dream alone! Link to comment Share on other sites More sharing options...
rover Posted September 1, 2008 Share Posted September 1, 2008 Brilliant,Got it working with some bitmaps i had lying arround.Cant see why i didnt see the _GUICtrlButton_SetImageList etc before.Fairly easy concept.Thanks again rover and im sure this thread will help many others.@Datus Thanks, glad to help@ValuaterThanks, It's just my own 'dog and pony show' version of the ImageList helpfile examples I see fascists... Link to comment Share on other sites More sharing options...
JackDinn Posted March 27, 2009 Share Posted March 27, 2009 (edited) so i was just about to add a background .jpg to one of my buttons , dident think it would be more than one command looked up the GUICtrlSetImage and put it in. so iv made a button & set the image simple but nooo it dont work ? but it says quite clearly in the help GUICtrlSetImage Sets the bitmap or icon image to use for a control.&If used on a Button control the image will be displayed on the button.but having found this thread im wondering how this command was used before all the _UDF's were added cos this command has been there for a long time ? ?and why is it that you can use it to add a background to some controls but not others ie buttons ?Just wondering cos your responses are lot of lines of script & messing about changing .jpg's to Icons just to put a background .jpg to a button.Cheers all.p.s also noticed a problem with this solution my post Edited March 27, 2009 by JackDinn Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D 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