在vc中要对CEdit控件的回车事件进行响应需要在窗口中响应PreTranslateMessage事件来变相实现,参考代码如下:
BOOL CAddrListDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message == WM_KEYDOWN) {
if(pMsg->wParam == VK_RETURN) {
UINT nID = GetFocus()->GetDlgCtrlID();
switch(nID){
case IDC_TXT_INPUTGROUP:
m_sta_inputgroup.ShowWindow(SW_HIDE);
m_txt_inputgroup.ShowWindow(SW_HIDE);
return TRUE;
//break;
}
}
}
return CDialog::PreTranslateMessage(pMsg);
}