ESC (エスケープ キー) を押して、mfc ダイアログ アプリケーションの終了を停止するにはどうすればよいですか。アプリケーションを実行した後、ESC キーを押すとウィンドウが閉じます。どうすればこれを止めることができますか? VC++ 6.0 を使用しています。
1714 次
4 に答える
4
OnCancelイベントをオーバーライドして、IDCANCELがフォーカスされたアイテムである場合にのみ、OnCancel呼び出しで先に進むことができます。
void CMyDialog::OnCancel(void)
{
if(GetDlgItem(IDCANCEL) == GetFocus())
{
CDialog::OnCancel();
return;
}
}
于 2009-06-16T10:35:57.223 に答える
1
Override OnCancel and don't call the base class implementation.
Don't go near OnClose unless you know what you're doing, you risk breaking the behaviour for Alt-F4 and the X button.
I've always regarded PreTranslateMessage for things like this as using a thermo-nuclear weapon to crack a nut, but if it floats your boat...
于 2009-06-16T21:38:47.167 に答える