(I am using VS ++ 2005)
I set the control to the edit field (with identifier - ID_edit_box) in my dialog and connected (with the handler wizard) two variables for it: control ( c_editbox) and value ( v_editbox). I also associate a handler function OnEnChangeedit_boxwith this edit control. Suppose that we can enter only one digit in the edit box, and this digit can be 0 or 1. If we enter some other value - I want the contents of this edit window to be automatically cleared, so the user cannot see that he (in other words, the user cannot enter anything other than 0/1 in the edit field). I do this check in function OnEnChangeedit_box. Here is the code:
void CSDRDlg::OnEnChangeedit_box()
{
CWnd* pWnd;
CString edit_box_temp;
pWnd = GetDlgItem(ID_edit_box);
pWnd->GetWindowText(edit_box_temp);
if ((edit_box_temp == "0" || edit_box_temp == "1")
{...do something - i.e. setfocus on some other edit box }
else
{
pWnd->SetWindowText("");
}
}
, : pWnd->SetWindowText(""); , , .
:
void CSDRDlg::OnEnChangeedit_box()
{
UpdateData(TRUE);
if ((v_editbox == "0" || v_editbox== "1")
{...do something - i.e. setfocus on some other edit box }
else
{
v_editbox = "";
UpdateData(FALSE);
}
}
, , - , ,
v_editbox = "";
UpdateData(FALSE);
.
Melinda