Stopping ESC and Return From Closing a Dialog

Date: 3 April 1997
Author: Christopher Kohlhoff

ESC sends a WM_COMMAND message to your dialog with IDCANCEL as the id. To stop ESC from closing the dialog, just add:

DEFINE_RESPONSE_TABLE1(TMyDialog, TDialog)
  // ...
  EV_COMMAND(IDCANCEL, OnCancel),
  // ...
END_RESPONSE_TABLE;

void TMyDialog::OnCancel()
{
  // Do nothing
}

 

Return sends a WM_COMMAND message to your dialog with IDOK as the id, provided there is no other button currently set as the default (surrounded by a thick black border). To stop Return from closing the dialog, add:

DEFINE_RESPONSE_TABLE1(TMyDialog, TDialog)
  // ...
  EV_COMMAND(IDOK, OnOK),
  // ...
END_RESPONSE_TABLE;

void TMyDialog::OnOK()
{
  // Do nothing
}