Question

I have a dialog box (CDialog) with owner-drawn CTabCtrl in it. Tabs content are child dialogs (one for each tab). There is an CEdit in each tab. When the user clicks a tab, I'm hiding all child dialogs using ShowWindow(SW_HIDE) and showing a selected one.

The problem is that when I have, for example, two tabs, click inside an edit box in the first tab and then switch to second, input focus stays on that (invisible) edit box in the first tab no matter what I do in my code (tried calling all methods that potentially can set focus, nothing changed).

Was it helpful?

Solution

Try this:

GetDlgItem(IDC_YOURCONTROL)->SetFocus();

Or the related variable linked with the control:

m_YOURCONTROLControl.SetFocus();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top