• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 331
  • Last Modified:

How to Make Edit Control Read Only

I have created a View Drived from FormView. Also I have Inserted a
Edit Box from Resource Editor on My Dialog/Form. Now i want to
make the Edit Control Read Only at RunTime(by code not on Intial Setting).
0
kakamna
Asked:
kakamna
  • 2
1 Solution
 
RAVIDCommented:
hi,
put what ever text u want to put into the edit box like
m_edit.SetWindowText(...);
then disable it using
m_edit.EnableWindow(FALSE);

here m_edit is the member variable of ur edit control.add this where ever u want to make it read only.


regards.
0
 
ZoppoCommented:
Hi kakamna,

To RAVID: what your code does is makeing a edit box disabled, which is not exactly the same as read-only: In a read-only edit box the user can still select the text and copy it to the clipboard, in a disabled edit box the user cannot select any text.

To set a edit box to read-only just use the CEdit::SetReadOnly() function, i.e.:

m_edit.SetWindowText(...);
m_edit.SetReadOnly( TRUE );

hope that helps,

ZOPPO
0
 
RAVIDCommented:
hi,

u can also use

m_edit.ModifyStyle(0,ES_READONLY,0);

to get the read only property

cheers
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now