Changing a edit box to static or read only

Started by tpekar, August 16, 2012, 07:12:59 PM

Previous topic - Next topic

tpekar

I was wondering if anyone can show me how to change an edit box control to static, or if not, at least make it read only?  I would also need to change it back.

Stefan Pendl

You would use the EM_SETREADONLY message to change the edit control to read only and back.

You could also disable it if the user shouldn't even be allowed to copy the contents of the edit control.
---
Stefan

Proud member of the UltraDefrag Development Team

tpekar

That worked.  Thanks!!  Question.  How come EM_SETREADONLY and not ES_READONLY?

Stefan Pendl

EM = Edit Message ... you use the message to change the behavior of the control after it is created

ES = Edit Style ... you can only apply the style when you create the control

To change the style without the message, you would need the GetWindowLong and SetWindowLong functions, see the remarks of the page linked above.

Always make sure to read the whole page, especially the remarks and requirements.
---
Stefan

Proud member of the UltraDefrag Development Team