开发者

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

开发者 https://www.devze.com 2023-03-02 17:06 出处:网络
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 dialo

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 o开发者_JS百科ne.

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();
0

精彩评论

暂无评论...
验证码 换一张
取 消