I hope this will be the last question I have to ask for awhile...
I know that you can set the ES_READONLY property in the Window Styles section to make a textbox read-only. What I want to do is, in code at runtime, make a textbox read only or editable via a function call. I don't want to use enable/disable because when you disable a control it makes the text grey as well.
Any thoughts?
There are two way's:
* set/unset the style via SetWindowLong %ES_READONLY
* Subclass the edit control, and when needed reject inputs
'set style (do not allow user to change textbox contents)
lStyle = GetWindowLong(GetDlgItem(CBHNDL, %ID_TEXTBOX), %GWL_STYLE)
lStyle = (lStyle OR %ES_READONLY)
SetWindowLong GetDlgItem(CBHNDL, %ID_TEXTBOX), %GWL_STYLE, lStyle
'
'unset style (allow user to change textbox contents)
lStyle = GetWindowLong(GetDlgItem(CBHNDL, %ID_TEXTBOX), %GWL_STYLE)
lStyle = (lStyle AND NOT %ES_READONLY)
SetWindowLong GetDlgItem(CBHNDL, %ID_TEXTBOX), %GWL_STYLE, lStyle
Here is an even easier way: :)
SendMessage HWND_FORM1_TEXT1, %EM_SETREADONLY, %TRUE, 0
%TRUE sets the control to read only, %FALSE makes it editable.
Here is the link to the edit control styles:
http://msdn2.microsoft.com/en-us/library/bb775464.aspx
Wow, that's really much easier ;)
Happy new year to everyone!!!
Wow! Impressive indeed!
Thanks.
nb