AndyS19 Posted June 11, 2015 Share Posted June 11, 2015 I have a menu item that is set up as a checkbox. When it's checked, I see the little box around the checkmark. But when I set the item to unchecked, I don't see the empty box.Here is a test script:expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() Local $iIDView, $iIDToggle, $val GUICreate("My GUI menu", 100, 100) $iIDView = GUICtrlCreateMenu("View", -1, 1) $iIDToggle = GUICtrlCreateMenuItem("", $iIDView) setChecked($iIDToggle, True) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idCancel Exit Case $iIDToggle $val = isChecked($iIDToggle) setChecked($iIDToggle, (Not $val)) EndSwitch WEnd EndFunc ;==>Example Func setChecked($id, $truefalse) Local $was, $setto, $label, $state = GUICtrlRead($id) $truefalse = ($truefalse) ? True : False $was = (BitAND($state, $GUI_CHECKED) == $GUI_CHECKED) ? True : False ; First, clear the $GUI_CHECKED and $GUI_UNCHECKED bits $setto = BitAND($was, (Not BitOR($GUI_CHECKED, $GUI_UNCHECKED))) ; Now set one or the other of them, based on the $truefalse value. If ($truefalse == True) Then $setto = BitOR($setto, $GUI_CHECKED) $label = "Checked" Else $setto = BitOR($setto, $GUI_UNCHECKED) $label = "Unchecked" EndIf GUICtrlSetState($id, $setto) GUICtrlSetData($id, $label) EndFunc ;==>setChecked Func isChecked($id) Local $ret, $state = GUICtrlRead($id) If (BitAND($state, $GUI_CHECKED) == $GUI_CHECKED) Then Return (True) Else Return (False) EndIf EndFunc ;==>isChecked Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 11, 2015 Moderators Share Posted June 11, 2015 AndyS19,Welcome to the AutoIt forums.Setting an empty string as the first parameter in GUICtrlCreateMenuItem creates a separator bar - so you have nothing to change. Change that line to read:$iIDToggle = GUICtrlCreateMenuItem(" ", $iIDView)and all should be well.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...
AndyS19 Posted June 12, 2015 Author Share Posted June 12, 2015 I tried your suggestion. Each time the menu item is clicked, I toggle the setting as well as change the menu text. If you run my example code, you would see the bad behavior. I ran Notepad and toggled the "Format => Word Wrap" menu option and I see the same behavior. Perhaps I could do something like adding an icon that looks like the empty box. The bottom line is that my users don't get a visual clue that the menu item is a think that they could click on to toggle the option settings. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 12, 2015 Moderators Share Posted June 12, 2015 AndyS19,I ran Notepad and toggled the "Format => Word Wrap" menu option and I see the same behaviorBecause what you complain of is the standard behaviour. So stop worrying and just let the user work it out for themselves - or explain in the Help documentation you of course provide for your app.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...
AndyS19 Posted June 12, 2015 Author Share Posted June 12, 2015 OK, 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