当前是button就点击?return,否则??下个控件是button就点击 return,否则?下个控件获得焦点 return。
BOOL PrintAllDlg::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN) //按下回车,当前是button,则点button reuturn。下个控件是button(2),则点button2,否则下个控件获得焦点
{
CWnd *wnd = GetFocus(); //当前控件
if (wnd != NULL)
{
char className[256];
GetClassName(wnd->m_hWnd, className, sizeof(className));
if (CString("Button") == className)
{
SendMessage(WM_COMMAND, wnd->GetDlgCtrlID(), (LPARAM)wnd->m_hWnd); //点击按钮
return TRUE;
}
}
CWnd *mwnd = GetNextDlgTabItem(wnd); //下个控件
if (mwnd)
{
char className[256];
GetClassName(mwnd->m_hWnd, className, sizeof(className));
if (CString("Button") == className)
{
SendMessage(WM_COMMAND, mwnd->GetDlgCtrlID(), (LPARAM)mwnd->m_hWnd);
return TRUE;
}
mwnd->SetFocus();
return TRUE;
}
}
return CDialogEx::PreTranslateMessage(pMsg);
}
|