Say I have an edit box in a MFC application (let's call it IDC_EDITBOX), and I enable (because I have it greyed out by default)it using

GetDlgItem(IDC_EDITBOX)->EnableWindow(TRUE)

How do I set the focus to that control? In other words, when I enable the control, how can I get the cursor to be in the edit box without the user clicking the mouse in the edit box?

Try:

GetDlgItem(IDC_EDITBOX)->SetFocus();

regards Niek

Thank you!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.