Edit Box Problem!!
C / C++ / MFC
4
Posts
4
Posters
0
Views
1
Watching
-
- I recently try to create a password protection program!!! But the problem was when I press "ENTER" in the edit box it will exit the program!!!! Anyone know how to fix this problem!!!(I want the Password check box checked in the property of edit box)!! 2) Are there a WM_KEYDOWN event for the edit box control???? What I want to do is when the user press "enter" key in the edit box it will checks to see if the password entered is it correct or not!!!! Any Help with these 2 problems???? THANKS FOR THE HELPER!~!!!!
-
- I recently try to create a password protection program!!! But the problem was when I press "ENTER" in the edit box it will exit the program!!!! Anyone know how to fix this problem!!!(I want the Password check box checked in the property of edit box)!! 2) Are there a WM_KEYDOWN event for the edit box control???? What I want to do is when the user press "enter" key in the edit box it will checks to see if the password entered is it correct or not!!!! Any Help with these 2 problems???? THANKS FOR THE HELPER!~!!!!
You need to override PreTranslateMessage for your dialog, then when you recieve a WM_KEYDOWN message that is VK_RETURN, check to see if the window handle of the message is equal to the window handle of the edit box, if so handle the message, otherwise pass it on to the base class.
-
- I recently try to create a password protection program!!! But the problem was when I press "ENTER" in the edit box it will exit the program!!!! Anyone know how to fix this problem!!!(I want the Password check box checked in the property of edit box)!! 2) Are there a WM_KEYDOWN event for the edit box control???? What I want to do is when the user press "enter" key in the edit box it will checks to see if the password entered is it correct or not!!!! Any Help with these 2 problems???? THANKS FOR THE HELPER!~!!!!
-
- I recently try to create a password protection program!!! But the problem was when I press "ENTER" in the edit box it will exit the program!!!! Anyone know how to fix this problem!!!(I want the Password check box checked in the property of edit box)!! 2) Are there a WM_KEYDOWN event for the edit box control???? What I want to do is when the user press "enter" key in the edit box it will checks to see if the password entered is it correct or not!!!! Any Help with these 2 problems???? THANKS FOR THE HELPER!~!!!!
Hi, I think the solution for both problems is to override the "OnOK" handler of the dialog:
void MyDialog::OnOK()
{
// suppose m_sPassword is bound with DDX to the editbox
UpdateData( TRUE );if( m\_sPassword != "PASSWORD" ) { AfxMessageBox( "Wrong Password" ); return; } CDialog::OnOK();
}
Best regards Holger