I have a edit box. The variable associated with the edit box is "CString m_edit1". I want to know how to disable the edit box or enable the edit box.
please advice.
Printable View
I have a edit box. The variable associated with the edit box is "CString m_edit1". I want to know how to disable the edit box or enable the edit box.
please advice.
Hi
Use the Resource ID attached to that edit box for enabling or disabling the edit box.
EX: say IDC_EDIT1 is your resource Id for that edit box then,
//to disable
GetDlgItem(IDC_EDIT1)->EnableWindow(FALSE);
//to enable
GetDlgItem(IDC_EDIT1)->EnableWindow(TRUE);
Regards
SKP
Be sure to rate answers if it helped, to encourage them.
you can use two ways:
1. Create a variable control for your edit box
ex: CEdit m_cedit1
then type this code:
m_cedit1.EnableWindow(0):To disable
m_cedit1.EnableWindow(1):To enable
2. get the control id of the control edit box(see in properties of edit box)
Then type this code:
GetDlgItem(control_id)::EnableWindow(0): To disable
GetDlgItem(control_id)::EnableWindow(1): To enable.
Hope it helps you...
Please rate if this one answers your problem
You need to create a CEdit for your edit box, just like how you create the variable except in this case you select 'Control' instead of 'Value' from the Category combo. Then you can use// m_ctrlEdit is the CEdit object that you have created for your edit box
m_ctrlEdit.EnableWindow(/* TRUE or FALSE */);
Chen Weiye
--------------------------------------------------------------------------------------------
When pursuing your dream, don't forget to enjoy your life...
--------------------------------------------------------------------------------------------