我定义了一个对话框CBtndlg,我想用对话框捕捉OnChar 消息,我就编写了下面的函数void CBtndlg::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
/*if(nChar==0X41)
{
GetDlgItem(IDC_EDIT1)->GetNextWindow()->SetFocus();
}*/
if(nChar==0X0D)
{
MessageBox("wo kao!!!");
}
CDialog::OnChar(nChar, nRepCnt, nFlags);
}
发现我按下键盘Enter键没有调用OnChar函数,我设置断点发现按下Enter键没进入OnChar函数 请大虾们指点一下小弟,小弟在此谢过!!!!!
{
// TODO: Add your message handler code here and/or call default
/*if(nChar==0X41)
{
GetDlgItem(IDC_EDIT1)->GetNextWindow()->SetFocus();
}*/
if(nChar==0X0D)
{
MessageBox("wo kao!!!");
}
CDialog::OnChar(nChar, nRepCnt, nFlags);
}
发现我按下键盘Enter键没有调用OnChar函数,我设置断点发现按下Enter键没进入OnChar函数 请大虾们指点一下小弟,小弟在此谢过!!!!!
BOOL MyDialog::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message == WM_KEYDOWN)
{
if( pMsg->wParam == VK_RETURN )
{
//如果按下了回车键,则....
} }
else if( pMsg->wParam == VK_TAB )
{
//如果按下了TAB键,则
}
else if( pMsg->wParam == VK_ESCAPE )
{
//按Esc键时,相当于按窗口上有的EXIT按钮.
}
//other events
}
return CDialog::PreTranslateMessage(pMsg);
}