buymeapc Posted March 1, 2018 Share Posted March 1, 2018 (edited) Hi all, Does anyone know how to change the state (checked/unchecked) image of a checkbox control? I'd like to use custom icons for checked/unchecked states when the control is clicked. Is it even possible? Thanks! Edit: Here's how I'm doing it now, which isn't very elegant #include <GUIConstantsEx.au3> #include <StaticConstants.au3> Global $g__bBool = False $hGUI = GUICreate("Test", 200, 200) $idIcon = GUICtrlCreateIcon("C:\Users\username\Documents\checkbox_empty.ico", 0, 10, 70, 13, 13) $idLabel = GUICtrlCreateLabel(" " & "Something", 10, 70, (50 + 18), 17, BitOR($GUI_SS_DEFAULT_LABEL, $SS_NOTIFY)) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $idIcon, $idLabel $g__bBool = Not $g__bBool If $g__bBool Then GUICtrlSetImage($idIcon, "C:\Users\username\Documents\checkbox_filled.ico", 0, 0) Else GUICtrlSetImage($idIcon, "C:\Users\username\Documents\checkbox_empty.ico", 0, 0) EndIf EndSwitch WEnd Edited March 1, 2018 by buymeapc Link to comment Share on other sites More sharing options...
Danp2 Posted March 2, 2018 Share Posted March 2, 2018 Have you read the remarks section of GUICtrlSetImage, specificly this portion? Quote Images can also be set for Checkbox controls as long as the $BS_PUSHLIKE style is used. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
jdelaney Posted March 2, 2018 Share Posted March 2, 2018 It seems the image is not on the checkbox itself though...can check help file for _GUICtrlButton_SetImageList _GUICtrlButton_SetImage IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
buymeapc Posted March 2, 2018 Author Share Posted March 2, 2018 Hmm...I don't think I'm quite understanding how to implement this properly. If I use $BS_PUSHLIKE, it looks like a button and not a checkbox. However, if I remove that style and set it back as $BS_AUTOCHECKBOX, I now see the original checkbox and the custom one I'm adding. Also, when I hover over the checkbox, the "checked" icon shows up until I move the mouse cursor away... #include <GUIButton.au3> #include <GUIConstantsEx.au3> #include <GUIImageList.au3> #include <ButtonConstants.au3> #include <StaticConstants.au3> Global $g__bBool = False $hGUI = GUICreate("Test", 200, 200) $hImage = _GUIImageList_Create(16, 16, 5, 3) _GUIImageList_AddIcon($hImage, "C:\Users\username\Documents\checkbox_empty.ico") _GUIImageList_AddIcon($hImage, "C:\Users\username\Documents\checkbox_filled.ico") ;$idCheck = GUICtrlCreateCheckbox("Something", 10, 70, 68, 17, $BS_PUSHLIKE); <<<< This shows a button without a checkbox $idCheck = GUICtrlCreateCheckbox("Something", 10, 70, 68, 17, $BS_AUTOCHECKBOX); <<<< This looks better, but shows the original *and* custom checkboxes _GUICtrlButton_SetImageList($idCheck, $hImage) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
orbs Posted March 2, 2018 Share Posted March 2, 2018 there is this UDF for tristate checkbox in a treeview control, it uses its own images for the checkboxes of the treeview control. you may learn from that how to apply the same concept to an individual checkbox control. also, if anyone knows how to do this, it would probably be the graphics grand master @UEZ Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
UEZ Posted March 2, 2018 Share Posted March 2, 2018 @buymeapc: check this out: 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