CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Location
    Bangalore,India
    Posts
    18

    Validation of the Edit control's Data in Wizard

    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.

  2. #2
    Join Date
    Apr 1999
    Posts
    306

    Re: Validation of the Edit control's Data in Wizard

    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);

    }



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured