jonny1234 Posted December 8, 2006 Posted December 8, 2006 Hi, To make an edit control read only without disabling it, I know you can use: GUICtrlSendMsg($Edit1, $EM_SETREADONLY, 1, 0) but it is possible to do the same for other controls so that they just read only and not greyed out? The reason I am asking is because I would like to make a form with several controls on it, which I plan to allow the user to change the contents of after they have pressed an Edit button. At this point I would highlight the controls whose contents they can edit. When they commit the changes, I would put all the controls back to the previous state again. But I don't want to disable the controls as their contents would then become greyed out and difficult to read. The controls in question are edit controls, date pickers, check boxes, combo boxes, radio buttons and list views. I would appreciate any suggestions. Regards, Jonny
JSThePatriot Posted December 8, 2006 Posted December 8, 2006 Hi, To make an edit control read only without disabling it, I know you can use: GUICtrlSendMsg($Edit1, $EM_SETREADONLY, 1, 0) but it is possible to do the same for other controls so that they just read only and not greyed out? The reason I am asking is because I would like to make a form with several controls on it, which I plan to allow the user to change the contents of after they have pressed an Edit button. At this point I would highlight the controls whose contents they can edit. When they commit the changes, I would put all the controls back to the previous state again. But I don't want to disable the controls as their contents would then become greyed out and difficult to read. The controls in question are edit controls, date pickers, check boxes, combo boxes, radio buttons and list views. I would appreciate any suggestions. Regards, Jonny Possibly consider instead of changing the state of the control just change the foreground (text) of the control to say red to show it is being edited. JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)
jonny1234 Posted December 8, 2006 Author Posted December 8, 2006 Possibly consider instead of changing the state of the control just change the foreground (text) of the control to say red to show it is being edited.Thanks for your reply JS, but this is not an option as it allows the users to just start typing without having activated edit mode (which they will do).I know it's possible to change the colours of disabled controls; I have seen it done, but I can't find any information on it.Regards,Jonny
jonny1234 Posted December 8, 2006 Author Posted December 8, 2006 Like this? #include <GuiConstants.au3> GuiCreate("Input Test", 392, 316,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $inputTest = GuiCtrlCreateEdit("Try To Change Me", 100, 110, 130, 60) GUICtrlSetStyle($inputTest, $ES_READONLY) GUICtrlSetBkColor($inputTest, 0xffffff) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd ExitRead the first post and get back to me. Regards, Jonny
ReverendJ1 Posted December 8, 2006 Posted December 8, 2006 Yeah I guess i misread that the first time, i was just rereading it and deleted my post.
ReverendJ1 Posted December 8, 2006 Posted December 8, 2006 (edited) You could always reset them whenever they are clicked i.e. #include <GUIConstants.au3> ; == GUI generated with Koda == $Form1 = GUICreate("AForm1", 622, 136, 192, 125) $Edit = GUICtrlCreateEdit("You can"&Chr(39)&"t change me.", 16, 16, 185, 89) GUICtrlSetStyle(-1, $ES_READONLY) GUICtrlSetBkColor(-1, 0xffffff) $Date = GUICtrlCreateDate("2006/12/08 13:37:25", 216, 16, 186, 21) $Checkbox = GUICtrlCreateCheckbox("Checkbox", 216, 48, 73, 17) $Combo = GUICtrlCreateCombo("", 216, 80, 145, 21) GUICtrlSetData(-1, "You|Cannot|Pick|These") GUICtrlSetStyle(-1, $ES_READONLY) GUICtrlSetBkColor(-1, 0xffffff) $Listbox = GUICtrlCreateList("", 424, 16, 121, 97) GUICtrlSetData(-1, "1 Try|2 To|3 Change|4 This") GUICtrlSetData(-1, "1 Try") $Radio = GUICtrlCreateRadio("Radio", 296, 48, 73, 17) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Date GUICtrlSetData($Date, "2006/12/08 13:37:25") Case $msg = $Checkbox GUICtrlSetState($Checkbox, $GUI_UNCHECKED) Case $msg = $Radio GUICtrlSetState($Radio, $GUI_UNCHECKED) Case $msg = $Listbox GUICtrlSetData($Listbox, "1 Try") Case Else ;;;;;;; EndSelect WEnd Exit Combo boxes also allow you to just set them as read only. Edited December 8, 2006 by ReverendJ1
jonny1234 Posted December 9, 2006 Author Posted December 9, 2006 Thanks for your reply. I did consider this method, but rejected it because it involves saving and restoring the contents of many controls, which can result in a flickering mess, which you then try to minimize by using form-level flags and/or controlling the redrawing of controls. But the solution isn't normally that great. However, time is running out for me to find out how to change the text colour of disabled controls (I know it's possible), so I may have to go for this workaround. Regards, Jonny
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