对话框中的编辑框不能响应回车键,是因为对话框中的VK_RETURN消息被传给了OnOK,解决方法:
CString m_edit;
.........
void CxxxDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_edit);
}
..........
重载PreTranslateMessage
BOOL CXXXDlg:: PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN || pMsg->wParam == VK_SPACE ){
if (pMsg->wParam == VK_RETURN) {
UpdateData();
MessageBox(m_edit);
}
else{
::TranslateMessage(pMsg);
: ispatchMessage(pMsg);
}
return TRUE;
}
return CDialog: reTranslateMessage(pMsg);
}
本文地址:http://com.8s8s.com/it/it26362.htm