WideBoyDixon Posted April 1, 2009 Posted April 1, 2009 Not sure where I stand on cross-posting a topic from the help forum here but I thought it was interesting so feel free to chastise me The following example toggles a checkbox to be read only: #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 Useful if you want to have the checkbox there for displaying a setting rather than allowing the user to change the setting. Also, a bit more elegant than simply disabling the control WBD [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]
gseller Posted April 2, 2009 Posted April 2, 2009 Nice example.. I have actually used this in another script that I made a few moons ago..
Yashied Posted April 2, 2009 Posted April 2, 2009 (edited) Very good. Edited April 2, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
KaFu Posted April 2, 2009 Posted April 2, 2009 Sorry, doesn't work for me , but changes style of checkbox to controlgroup ... Effect only visible if you redraw the window, either by api call (see code below) or if you minimize/maximize the gui... #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <Constants.au3> $gui = 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) _WinAPI_RedrawWindow($gui) EndFunc OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
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