How can I get and set the 'read-only' property of an edit box?
From stackoverflow
-
From the design window: right-click the edit box, select properties. Its the last option on the Styles tab.
-
The CEdit class has a SetReadOnly method which can be called at run-time. Details on MSDN: http://msdn.microsoft.com/en-gb/library/aa279328(VS.60).aspx
Joel : How are you calling it? If you're doing something like GetDlgItem(blah)->SetReadOnly, then you'll probably get an error message like that, because GetDlgItem doesn't return a CEdit.Joel : Probably the best way is to use the ClassWizard to set up a member variable for the control or controls you want to change and manipulate the edit control through that. You could probably cast the CWnd* to a CEdit*, but I wouldn't unless you're just out of other options.Mark Ransom : Actually casting CWnd* to CEdit* is idiomatic MFC. Just one of the many reasons it gets no respect. -
GetDlgItem(blah)->SendMessage(EM_SETREADONLY ,1 ,0);
This will set it to read only.
0 comments:
Post a Comment