SlowCoder74 Posted December 18, 2014 Share Posted December 18, 2014 I spent quite a while trying to figure out why I couldn't set an icon to my button, using BrewManNH's sample below. Then I decided to strip the code until I determined why it wouldn't draw. I found that apparently _GUICtrlButton_SetImageList() doesn't work if GUICtrlSetColor() is used on the same control. BrewManNH's sample: My test code: #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #include <GuiButton.au3> #include <guiimagelist.au3> #Region ### START Koda GUI section ### $frmMain = GUICreate("", 730, 530, -1, -1) $btnClose = GUICtrlCreateButton("Close", 560, 472, 161, 24) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") ;GUICtrlSetColor(-1, 0x800000) GUISetState() #EndRegion ### END Koda GUI section ### $hImage = _GUIImageList_Create(16, 16, 5) _GUIImageList_AddIcon($hImage, "Cancel.ico") _GUICtrlButton_SetImageList($btnClose, $hImage) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Why is this a problem? Well, my project has buttons inside group controls. The group controls have the title text set in a different color. Since controls within the group controls take on the colors of their parents by default, I have to set the color of each child control individually. In doing that, _GUICtrlButton_SetImageList() breaks. Any ideas? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 18, 2014 Moderators Share Posted December 18, 2014 SlowCoder74,Colouring buttons is not a good idea - as several threads have explained in the past. There is a bug deep within the AutoIt core code (which means it will not be fixed any time soon - see #376) which causes all sorts of problems when buttons are coloured - they trap the ENTER key, lose styles 9as you have discovered) and generally misbehave. In my opinion, best not to colour buttons. 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...
SlowCoder74 Posted December 18, 2014 Author Share Posted December 18, 2014 Melba, I would expect nothing less than a near-instant reply from you. The bug report you linked only seems to cite GUICtrlSetBkColor(), not GUICtrlSetColor(). Is GUICtrlSetColor() also affected in the same scope? (I know that sounds like a dumb question, as I'm having problems with it, but one can never be too sure.) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 18, 2014 Moderators Share Posted December 18, 2014 SlowCoder74,I have no idea, but it would not surprise me in the least. 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...
UEZ Posted August 13, 2015 Share Posted August 13, 2015 Might be an alternative: https://www.autoitscript.com/forum/topic/173350-dwmtransparent-button/?do=findComment&comment=1254068 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ 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