Edifice Posted April 1, 2009 Share Posted April 1, 2009 Got a bit of dissapointment as I mis-read the helpfile, and thought I could prevent users from checking the checkbox by flagging it with $ES_READONLY as I discovered this flag only covers input controls. Any other way to do this? Link to comment Share on other sites More sharing options...
Nahuel Posted April 1, 2009 Share Posted April 1, 2009 Try: GuiCtrlSetState($CheckBoxID,$GUI_DISABLE) Link to comment Share on other sites More sharing options...
WideBoyDixon Posted April 1, 2009 Share Posted April 1, 2009 #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <Constants.au3> GUICreate("Test", 128, 128) Global $chkTest = GUICtrlCreateCheckbox("Test", 8, 8, 48, 16) Global $btnToggle = GUICtrlCreateButton("Normal", 8, 32, 96, 24) GUISetState() Global $uiMsg = 0 While $uiMsg <> $GUI_EVENT_CLOSE $uiMsg = GUIGetMsg() If $uiMsg = $btnToggle Then ToggleReadOnly(GUICtrlGetHandle($chkTest)) EndIf Sleep(10) Wend Exit Func ToggleReadOnly($hWnd) Local $iStyle = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE) If BitAND($iStyle, 4) Then $iStyle -= 4 GUICtrlSetData($btnToggle, "Normal") Else $iStyle += 4 GUICtrlSetData($btnToggle, "Read Only") EndIf _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, $iStyle) EndFunc [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center] Link to comment Share on other sites More sharing options...
Nahuel Posted April 1, 2009 Share Posted April 1, 2009 Excellent example, but using $GUI_DISABLE not only is enough, but also makes it visible that the checkbox is read-only: #include <GUIConstantsEx.au3> #include <Constants.au3> GUICreate("Test", 128, 128) Global $chkTest = GUICtrlCreateCheckbox("Test", 8, 8, 48, 16) Global $btnToggle = GUICtrlCreateButton("Read Only", 8, 32, 96, 24) GUISetState() Global $uiMsg = 0 While $uiMsg <> $GUI_EVENT_CLOSE $uiMsg = GUIGetMsg() If $uiMsg = $btnToggle Then ToggleReadOnly($chkTest) EndIf Sleep(10) Wend Exit Func ToggleReadOnly($hWnd) Local $iStyle = GUICtrlGetState($hWnd) If BitAND($iStyle,$GUI_DISABLE) Then GUICtrlSetState($chkTest,$GUI_ENABLE) GUICtrlSetData($btnToggle, "Read Only") Else GUICtrlSetState($chkTest,$GUI_DISABLE) GUICtrlSetData($btnToggle, "Normal") EndIf EndFunc Link to comment Share on other sites More sharing options...
WideBoyDixon Posted April 1, 2009 Share Posted April 1, 2009 I was adhering to the help request which asked for a readonly checkbox, not a disabled one [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center] Link to comment Share on other sites More sharing options...
Nahuel Posted April 1, 2009 Share Posted April 1, 2009 Good point. I stand corrected. Link to comment Share on other sites More sharing options...
Edifice Posted April 7, 2009 Author Share Posted April 7, 2009 Better late than never: Thanks guys! Really helped me out! 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