5月26
大家都知道用VC刚设计出来的对话框在build并debug的时候会出现个问题就是不管操作什么一按回车就会关闭对话框,这是VC默认的调用onok()这个函数,而默认的这个函数就是关闭功能,所以有两种方法去解决,在网上都能查到,我这里用重载PreTranslateMessage函数,在classwizard中选择对应对话框的类,然后在message中选择PreTranslateMessage,双击它即可,具体代码如下:
//CKaoqinDlg是我以前做课程设计时写的对话框名称
//CKaoqinDlg是我以前做课程设计时写的对话框名称
BOOL CKaoqinDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if((pMsg->message==WM_KEYDOWN) && (pMsg->wParam==VK_RETURN))
return true;
return CDialog::PreTranslateMessage(pMsg);
}
{
// TODO: Add your specialized code here and/or call the base class
if((pMsg->message==WM_KEYDOWN) && (pMsg->wParam==VK_RETURN))
return true;
return CDialog::PreTranslateMessage(pMsg);
}




