How do I set focus to CEdit in child dialog that is inside TabCtrl?

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).


Try this:

GetDlgItem(IDC_YOURCONTROL)->SetFocus();

Or the related variable linked with the control:

m_YOURCONTROLControl.SetFocus();
链接地址: http://www.djcxy.com/p/39254.html

上一篇: 隐藏的对话框需要关注一会儿

下一篇: 如何将焦点设置为TabCtrl中的子对话框中的CEdit?