Thursday, January 3, 2008

SetFocus to an Edit Control in a Dialog MFC

n your OnInitDialog handler for the dialog, set focus to the control with
something like...

((CEdit*)GetDlgItem(IDC_PREFERRED_EDIT_BOX))->SetFocus();

or via a control mapped variable...

m_ctrlPrefferedEditBox->SetFocus();

Finally, return FALSE from the OnInitDialog handler.

No comments: