Beginner Dialog::OnOK() Question
-
Hi, I have a dialog based application with the standard "Ok" and "Cancel" buttons at the bottom. After the dialog app loads, if I press the 'enter' key, the app closes (the Dialog::OnOK() Event Fires). How can I override this action? In other words, I want to be able to press the 'enter' key and not close the application (not fire the OnOK() event method). How do I do this? Thanks.
-
Hi, I have a dialog based application with the standard "Ok" and "Cancel" buttons at the bottom. After the dialog app loads, if I press the 'enter' key, the app closes (the Dialog::OnOK() Event Fires). How can I override this action? In other words, I want to be able to press the 'enter' key and not close the application (not fire the OnOK() event method). How do I do this? Thanks.
There are two ways to do this - 1. You can do this by overriding the OnOK function in your dialog class and do NOT call the base class OnOK in that function. 2. In the dialog editor remove the default button property of the OK button. Hope this helps Krishnan
-
Hi, I have a dialog based application with the standard "Ok" and "Cancel" buttons at the bottom. After the dialog app loads, if I press the 'enter' key, the app closes (the Dialog::OnOK() Event Fires). How can I override this action? In other words, I want to be able to press the 'enter' key and not close the application (not fire the OnOK() event method). How do I do this? Thanks.
Please see Mike Dunn's C++ FAQ, §7.4. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
-
Hi, I have a dialog based application with the standard "Ok" and "Cancel" buttons at the bottom. After the dialog app loads, if I press the 'enter' key, the app closes (the Dialog::OnOK() Event Fires). How can I override this action? In other words, I want to be able to press the 'enter' key and not close the application (not fire the OnOK() event method). How do I do this? Thanks.
Put in your own OnOK(0 for the dialog, and have code liek this:
CMyDialog::OnOK()
{
if (GetFocus() != GetDlgItem(IDOK))
return ; // only allow exit if OK has the focus
}Roger Allen Sonork 100.10016 If I'm not breathing, I'm either dead or holding my breath. A fool jabbers, while a wise man listens. But is he so wise to listen to the fool? Please step to the rear of the car and make room for more victims. - John Simmons the Outlaw programmer, 1st Feb 2002, in the lounge
-
Put in your own OnOK(0 for the dialog, and have code liek this:
CMyDialog::OnOK()
{
if (GetFocus() != GetDlgItem(IDOK))
return ; // only allow exit if OK has the focus
}Roger Allen Sonork 100.10016 If I'm not breathing, I'm either dead or holding my breath. A fool jabbers, while a wise man listens. But is he so wise to listen to the fool? Please step to the rear of the car and make room for more victims. - John Simmons the Outlaw programmer, 1st Feb 2002, in the lounge