且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

去掉默认回车关闭的方法

更新时间:2022-09-13 23:16:05

1 最简单的办法:添加一个不可见的按钮,设为对话框的默认按钮即可


2 重载对话框的PreTranslateMessage消息处理
BOOL CSIMDlg::PreTranslateMessage(MSG* pMsg)  
{
 // TODO: Add your specialized code here and/or call the base class
 if( pMsg->message ==WM_KEYDOWN)
 {
  if(pMsg->wParam == VK_ESCAPE||pMsg->wParam == VK_RETURN)
  return TRUE;
 }
 return CDialog::PreTranslateMessage(pMsg);
}