NO

Author Topic: Changing a edit box to static or read only  (Read 3121 times)

tpekar

  • Guest
Changing a edit box to static or read only
« on: August 16, 2012, 07:12:59 PM »
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.

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
Re: Changing a edit box to static or read only
« Reply #1 on: August 16, 2012, 10:38:21 PM »
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

  • Guest
Re: Changing a edit box to static or read only
« Reply #2 on: August 16, 2012, 10:59:25 PM »
That worked.  Thanks!!  Question.  How come EM_SETREADONLY and not ES_READONLY?

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
Re: Changing a edit box to static or read only
« Reply #3 on: August 17, 2012, 07:35:07 AM »
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