以下是代码:
void CMFCApplication5Dlg::OnBnClickedOk()
{
// TODO: 在此添加控件通知处理程序代码
if (GetFocus() == GetDlgItem(IDC_EDIT4))
GetDlgItem(IDC_EDIT1)->SetFocus();
else if (GetFocus()->GetDlgCtrlID() == IDOK)
CDialogEx::OnOK();
else
GetFocus()->GetNextWindow()->SetFocus();
}
WNDPROC prevproc;
LRESULT CALLBACK winsunproc(
HWND hwnd,
UINT uMsg,
WPARAM wParam, LPARAM IParam )
{
if (uMsg == WM_CHAR && wParam == 0xd)
{
//::SetFocus(::GetNextWindow(hwnd, GW_HWNDNEXT));
::SetFocus(::GetWindow(hwnd, GW_HWNDNEXT));
return 1;
}
else
{
return prevproc(hwnd, uMsg, wParam, IParam);
}
}
BOOL CAboutDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: 在此添加额外的初始化
prevproc = (WNDPROC)SetWindowLong(GetDlgItem(IDC_EDIT1)->m_hWnd,
GWL_WNDPROC, (LONG)winsunproc);
return FALSE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
四个编辑框都是这个设置: