Re: How to make TextBox read only but look normal
- Posted by AndyDrummond Jul 06, 2009
- 1324 views
OK, this works. If you have a flag - I called it ROflag - which is True to make the control RO, and false to allow RW. You intercept the w32HEvent flag, and you test ROflag. If true do a returnValue(). This stops everything. But that includes painting. So you would need to leave ROflag false until the control is painted, setting it again afterwards to make the control inviolate.
You would probably be best to save the flag value in the main window onPaint handler, clearing it to allow the text to be painted, and restoring it after to the RO or RW state.
Does this make sense? It isn't terribly hygienic but it works. You can't do ANYTHING to the text box if the w32HEvent returnValue()'s.
Now we wait for Derek to tell us how it SHOULD be done...
Andy