Click to See Complete Forum and Search --> : Validation of the Edit control's Data in Wizard


Kishore Kumar
May 28th, 1999, 01:17 AM
Hello Friends ,
I am working in a VC++ Project. I am facing a problem in validating the Edit control's data of Wizard (CPropertySheet). Problem description :
I have created a Wizard with 4 Pages. First Page is having one edit control (Name). I am validating the name in the Killfocus of the Name.If the name is not valid then I am showing a error message and again setting the focus to Name. Its working fine.
Wizard is showing Three buttons automatically (Back , Next , Cancel ). What I want is If user enters an Invalid Name (like empty string) and presses cancel button then Wizard should be closed. Its not happening. I know the reason. Even Cancel is pressed Killfocus of name is called and focus is again set to Name. So its failed. Another thing is Cancel button is automaticlly shown by the wizard. How to know the ID of the cancel button ? IDCANCEL is not working.
Please kindly help me. Thanks.

Kishore Kumar D
Bangalore.
India.

ric
May 28th, 1999, 07:38 AM
I have a similiar task recently. I have to put an edit control in a dialog that accepts only integers. So see my solution and may be it will help you or give you any ideas. In PreTranslateMessage() of the dialog class I do the following:

int CMyDialog::PretranslateMessage(MSG* pMsg)
{
if(pMsg->message == WM_CHAR)
if(GetDlgItem(IDC_EDIT1) == GetFocus())
if( ! isdigit(pMsg->wParam) ) return 1;

CDialog::PreTranslateMessage(pMsg);

}

for your problem you could do something similar:

int CMyDialog::PretranslateMessage(MSG* pMsg)
{
if(pMsg->message == WM_CHAR)
if(GetDlgItem(IDC_EDIT1) == GetFocus())
{
CString str;
GetDlgItemText(IDC_EDIT1,str);
if(str)
{
// Check the string
}
else
{
// NULL string
}
}

CDialog::PreTranslateMessage(pMsg);

}