boccverità Posted May 27, 2015 Share Posted May 27, 2015 HelloI created a Gui and there are 3 buttons, but if I set an image button, the button name disappears. How can I do? #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <file.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 322, 287, 318, 109) GuiCtrlCreatePic("C:\Documents and Settings\UserXP\Documenti\Downloads\sfondo.bmp",0,0,330,290) GuiCtrlSetState(-1,128) $Button1 = GUICtrlCreateButton("Leggi login e password", 120, 16, 89, 33, BitOR($BS_DEFPUSHBUTTON,$BS_BITMAP)) GUICtrlSetImage(-1, "C:\Documents and Settings\UserXP\Documenti\Downloads\fire.bmp", -1) $Button2 = GUICtrlCreateButton("Inserimento account", 120, 88, 89, 33, BitOR($BS_DEFPUSHBUTTON,$BS_BITMAP)) GUICtrlSetImage(-1, "C:\Documents and Settings\UserXP\Documenti\Downloads\fire.bmp", -1) $Button3 = GUICtrlCreateButton("Button3", 120, 152, 89, 33, BitOR($BS_DEFPUSHBUTTON,$BS_BITMAP)) GUICtrlSetImage(-1, "C:\Documents and Settings\UserXP\Documenti\Downloads\fire.bmp", -1) GUISetState(@SW_SHOW) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 27, 2015 Moderators Share Posted May 27, 2015 boccverità,To get text and images on a button you need to use ImageLists like this:expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiButton.au3> #include <GuiImageList.au3> ;Caveat: Minimum Operating Systems: Windows XP ;In XP, Multiple image list will only show images other than the 1st when Themes are used. $hGUI = GUICreate("Button Imagelists - Minimum OS: Windows XP", 500, 400) $cLabel = GUICtrlCreateLabel("", 150, 30, 300, 300) $sMsg = "The 'Changer' button shows what can be done." & @CRLF $sMsg &= "It displays 'Normal', but 'Hot' when under the cursor," & @CRLF $sMsg &= "Pressed when pressed, Disabled when disabled," & @CRLF $sMsg &= "and when it has focus it switches between Focus and Stylus." GUICtrlSetData($cLabel, $sMsg) ;multi state image Bitmap $cButton_1 = GUICtrlCreateButton("Changer", 30, 30, 90, 32) GUICtrlSetTip(-1, "Multi state bitmap imagelist") $hImageBtn_1 = _GUIImageList_Create(24, 24, 5, 5) _GUIImageList_AddIcon($hImageBtn_1, "shell32.dll", 27, True) ;1 - Normal _GUIImageList_AddIcon($hImageBtn_1, "shell32.dll", 77, True) ;2 - Hot (ie cursor over) _GUIImageList_AddIcon($hImageBtn_1, "shell32.dll", 144, True) ;3 - Pressed _GUIImageList_AddIcon($hImageBtn_1, "shell32.dll", 109, True) ;4 - Disabled _GUIImageList_AddIcon($hImageBtn_1, "shell32.dll", 130, True) ;5 - Focus button (switches between 5 & 6 in Vista) _GUIImageList_AddIcon($hImageBtn_1, "shell32.dll", 154, True) ;6 - Stylus Hot (tablet computers only) _GUICtrlButton_SetImageList($cButton_1, $hImageBtn_1) ;single state image Bitmap $cButton_2 = GUICtrlCreateButton("Disable", 30, 70, 90, 32) GUICtrlSetTip(-1, "Single bitmap imagelist") $hImageBtn_2 = _GUIImageList_Create(24, 24, 5, 3) _GUIImageList_AddIcon($hImageBtn_2, "shell32.dll", 131, True) _GUICtrlButton_SetImageList($cButton_2, $hImageBtn_2) ;single state image Icon $cButton_3 = GUICtrlCreateButton("Unlock", 30, 110, 90, 40) GUICtrlSetTip(-1, "Single icon imagelist") $hImageBtn_3 = _GUIImageList_Create(32, 32, 5, 3) _GUIImageList_AddIcon($hImageBtn_3, "shell32.dll", 47, True) _GUICtrlButton_SetImageList($cButton_3, $hImageBtn_3) ;single state image Bitmap with overlay text $cButton_4 = GUICtrlCreateButton("Help", 30, 160, 90, 90) GUICtrlSetTip(-1, "Single bitmap imagelist with overlayed text") GUICtrlSetFont(-1, 14, 800, -1, "Comic Sans MS") $hImageBtn_4 = _GUIImageList_Create(80, 80, 5, 3) _GUIImageList_AddIcon($hImageBtn_4, "shell32.dll", 116, True) _GUICtrlButton_SetImageList($cButton_4, $hImageBtn_4, 4) GUISetState() While 1 $sMsg = GUIGetMsg() Switch $sMsg Case $GUI_EVENT_CLOSE Exit Case $cButton_2 GUICtrlSetState($cButton_1, $GUI_DISABLE) Case $cButton_3 GUICtrlSetState($cButton_1, $GUI_ENABLE) EndSwitch WEndThe icon values are correct for Win7 - you may get some funny icons if you use another OS. And you can always use your own images by using _GUIImageList_AddBitmap and setting the path to the image.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
boccverità Posted May 27, 2015 Author Share Posted May 27, 2015 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