Knowledge Base Nr: 00039 Navigate_Edit_Dlg_MFC.cpp - http://www.swe-kaiser.de

Downloads:

MFC: dialog sample demonstrates switching between multiple CEdit controls
through ENTER key.
(using GetFocus() and SetFocus() inside of OnOK() )

  
void CTestDlg::OnOK()
{
CWnd* wnd = GetFocus();
CWnd* wnd1 = GetDlgItem(IDC_EDIT1);
CWnd* wnd2 = GetDlgItem(IDC_EDIT2);
CWnd* wnd3 = GetDlgItem(IDC_EDIT3);

if (wnd == wnd1)
wnd2->SetFocus();
else if (wnd == wnd2)
wnd3->SetFocus();
else if (wnd == wnd3)
wnd1->SetFocus();
else //ok button?!
CDialog::OnOK();
}