blindwig Posted April 22, 2005 Share Posted April 22, 2005 I have an edit control that I want to be able to toggle weather or not it is read-only in the script. I want to do this because I want the control to be readonly for certain conditions. I don't want to use GUICtrlSetState and $GUI_Disable because then the scroll bars don't work. But it seems like you can't affect the readonly status of an edit control once the control is created. Try this: $hndEdit_Test1 = GUICtrlCreateEdit("test1", 0, 0, 100, 100, 0) GUICtrlSetStyle($hndEdit_Test1, $ES_Readonly) ; Notice that the control is not readonly $hndEdit_Test1 = GUICtrlCreateEdit("test1", 0, 0, 100, 100, $ES_Readonly) GUICtrlSetStyle($hndEdit_Test1, 0) ; Notice that the control stays readonly The only thing I can think to do is when I want to change it, I need to save the data then destory it and create another edit box of the same size and shape and re-populate it. My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions Link to comment Share on other sites More sharing options...
CyberSlug Posted April 22, 2005 Share Posted April 22, 2005 (edited) Based on this recent post, try the following GuiCtrlSendMsg:#include <GuiConstants.au3> Global $EM_SETREADONLY = 0xCF; GuiCreate("Example") $hndEdit_Test1 = GUICtrlCreateEdit("test1", 0, 0, 100, 100, 0) $hndEdit_Test1 = GUICtrlCreateEdit("test1", 0, 0, 100, 100, $ES_Readonly) GuiSetState() GuiCtrlSendMsg($hndEdit_Test1, $EM_SETREADONLY, 0, 0);not read-only sleep(1000) GuiCtrlSendMsg($hndEdit_Test1, $EM_SETREADONLY, 1, 0);read-only sleep(1000) GuiCtrlSendMsg($hndEdit_Test1, $EM_SETREADONLY, 0, 0);not read-only While GuiGetMsg() <> $GUI_EVENT_CLOSE sleep(100) WEnd Edited April 22, 2005 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
jpm Posted April 22, 2005 Share Posted April 22, 2005 Based on this recent post, try the following GuiCtrlSendMsg:#include <GuiConstants.au3> Global $EM_SETREADONLY = 0xCF; GuiCreate("Example") $hndEdit_Test1 = GUICtrlCreateEdit("test1", 0, 0, 100, 100, 0) $hndEdit_Test1 = GUICtrlCreateEdit("test1", 0, 0, 100, 100, $ES_Readonly) GuiSetState() GuiCtrlSendMsg($hndEdit_Test1, $EM_SETREADONLY, 0, 0);not read-only sleep(1000) GuiCtrlSendMsg($hndEdit_Test1, $EM_SETREADONLY, 1, 0);read-only sleep(1000) GuiCtrlSendMsg($hndEdit_Test1, $EM_SETREADONLY, 0, 0);not read-only While GuiGetMsg() <> $GUI_EVENT_CLOSE sleep(100) WEnd<{POST_SNAPBACK}> in the current beta I did a correction to do the EM_setREADONLY when you request ES_READONLY by GUICtrlSetStyleCan you verify it is OK? Link to comment Share on other sites More sharing options...
buzz44 Posted April 22, 2005 Share Posted April 22, 2005 Like this? If so I think $EM_SETREADONLY should be included in the help file and in GUIConstants.au3. #include <GUIConstants.au3> $EM_SETREADONLY = 0xCF GUICreate("Test") $Check = GUICtrlCreateCheckbox ("Check", 10, 10, 120, 20) $Edit = GUICtrlCreateEdit("Edit", 50, 50, 100, 100) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exitloop If GUICtrlRead($Check) = $GUI_CHECKED then GUICtrlSetStyle($Edit, $ES_READONLY) Else GUICtrlSetStyle($Edit, $EM_SETREADONLY) EndIf WEnd qq Link to comment Share on other sites More sharing options...
jpm Posted April 22, 2005 Share Posted April 22, 2005 Like this? If so I think $EM_SETREADONLY should be included in the help file and in GUIConstants.au3.<{POST_SNAPBACK}>NO,NOlike that there is no need at least for this style modification just set ES_READONLY or reset GUI_SS_DEFAULT_EDIT#include <GUIConstants.au3> GUICreate("Test") $Check = GUICtrlCreateCheckbox ("Check", 10, 10, 120, 20) $Edit = GUICtrlCreateEdit("Edit", 50, 50, 100, 100) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exitloop if $msg=$check then If GUICtrlRead($Check) = $GUI_CHECKED then GUICtrlSetStyle($Edit, $ES_READONLY) Else GUICtrlSetStyle($Edit, $GUI_SS_DEFAULT_EDIT) EndIf endif WEnd Link to comment Share on other sites More sharing options...
buzz44 Posted April 22, 2005 Share Posted April 22, 2005 Ohhhhhhh. , I still think it should be included but, $EM_SETREADONLY that is. qq Link to comment Share on other sites More sharing options...
jpm Posted April 22, 2005 Share Posted April 22, 2005 Ohhhhhhh. , I still think it should be included but, $EM_SETREADONLY that is.<{POST_SNAPBACK}>Your example works just because you try to use $em_setreadonly which is not doing anything except not setting $es_readonly, so it is wrong to use with GuiCtrlSetStyle with this parameter.definetly it can be use with GUICtrlSendMsg but as we don't document all those msg we don't include them in the GUIConstants.au3 or in Constants.au3.I hope that clarify how to use es_readonly Link to comment Share on other sites More sharing options...
layer Posted April 22, 2005 Share Posted April 22, 2005 NO,NOlike that there is no need at least for this style modification just set ES_READONLY or reset GUI_SS_DEFAULT_EDIT#include <GUIConstants.au3> GUICreate("Test") $Check = GUICtrlCreateCheckbox ("Check", 10, 10, 120, 20) $Edit = GUICtrlCreateEdit("Edit", 50, 50, 100, 100) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exitloop if $msg=$check then If GUICtrlRead($Check) = $GUI_CHECKED then GUICtrlSetStyle($Edit, $ES_READONLY) Else GUICtrlSetStyle($Edit, $GUI_SS_DEFAULT_EDIT) EndIf endif WEnd <{POST_SNAPBACK}>Oddly, that example doesn't do anything to the readonly-ness FootbaG Link to comment Share on other sites More sharing options...
jpm Posted April 22, 2005 Share Posted April 22, 2005 Oddly, that example doesn't do anything to the readonly-ness <{POST_SNAPBACK}>it does with the correction in the beta version Link to comment Share on other sites More sharing options...
therks Posted April 23, 2005 Share Posted April 23, 2005 I notice that an Edit will change colour when you apply the ReadOnly style to it. Should not Input's do the same?Basically why I ask is I was trying to duplicate this effect without having to manually change the background color:Heh, noticing a weird bug too... have a look at this:CODE#include <GUIConstants.au3>GUICreate("Test")$Check = GUICtrlCreateCheckbox ("Check", 10, 10, 120, 20)$Input = GUICtrlCreateInput("Input", 50, 30, 100, 20)$Edit = GUICtrlCreateEdit("Edit", 50, 50, 100, 100)GUISetState()While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exitloop if $msg=$check then If GUICtrlRead($Check) = $GUI_CHECKED then GUICtrlSetStyle($Input, $ES_READONLY) GUICtrlSetState($Input, $GUI_DISABLE) GUICtrlSetStyle($Edit, $ES_READONLY) GUICtrlSetState($Edit, $GUI_DISABLE) Else GUICtrlSetStyle($Input, $GUI_SS_DEFAULT_INPUT) GUICtrlSetState($Input, $GUI_ENABLE) GUICtrlSetStyle($Edit, $GUI_SS_DEFAULT_EDIT) GUICtrlSetState($Edit, $GUI_ENABLE) EndIf endifWEndNote the text color and lack of scroll bars if you toggle back and forth. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
blindwig Posted April 26, 2005 Author Share Posted April 26, 2005 I'm using AutoIt 3.1.0.15 CyberSlug's suggestion worked for me - Thanks! My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions 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