Article ID: 122489 - Last Review: November 21, 2006 - Revision: 3.1 How to Disable Default Pushbutton Handling for MFC DialogThis article was previously published under Q122489 SUMMARY
Windows dialog boxes support the use of a default button (pushbutton) that
is automatically activated when the ENTER key is pressed while focus is not
on a command button. The MFC class library will automatically call the
CDialog::OnOK() virtual function for a dialog whenever the default button
(pushbutton) is activated by pressing the ENTER key. This behavior conforms to the guidelines set forth by "The Windows Interface: An Application Design Guide." This manual is included with the Windows version 3.1 SDK documentation. It is also available from Microsoft Press. MORE INFORMATION
Although default button (pushbutton) support is recommended, you might want
to disable or modify the standard implementation in certain situations. You
can do this in an MFC application by following these steps:
This same technique can be used to disable or modify default OnCancel processing. The escape key generates a call to CDialog::OnCancel just as the enter key generates an OnOK function call. APPLIES TO
| Article Translations
|

Back to the top
