在对话框上设置项目的选项卡顺序 [英] Setting tab order of item on the dialog

查看:118
本文介绍了在对话框上设置项目的选项卡顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在设置对话框中的制表符顺序时遇到问题.为了设置跳位顺序,我使用了功能SetWindowPos().

I am facing a problem in setting the tab order in a dialog box. To set the tab order I have used the function SetWindowPos().

最初,它将焦点集中在对话框中的一个项目上,但是如果我按Tab键,它将不会将焦点更改到对话框中的其他项目上.

Initially it will be focused to one of the dialog item, but if I press tab it will not change the focus to the other items on the dialog box.

请帮助他解决问题. 下面是代码...

Please help he to fix the problem. bellow is the code...

HWND hBtn1 = GetDlgItem(hWnd, IDC_BTN_OPEN);

HWND hBtn2 = GetDlgItem(hWnd, IDC_BTN_CLOSE);
HWND hBtn3 = GetDlgItem(hWnd, IDC_BTN_SAVE);

bool result = ::SetWindowPos(hBtn1, hBtn2, 0, 0, 0, 0,SWP_NOSIZE|SWP_NOMOVE);
result = ::SetWindowPos(hBtn2, hBtn3, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);

推荐答案

您真的必须通过代码设置制表符顺序吗? 只需在对话框设计器中按Ctrl + D!

Do you really have to set the tab order by code? Just press Ctrl+D in the dialog designer!

更新: 使用SetWindowPos不会对您有帮助.您认为它将定义Taborder的参数仅设置z顺序,这意味着在控件重叠时如何绘制控件的顺序.我不确定,但是我认为Tab键顺序是由控件的创建顺序定义的.

Update: Using SetWindowPos won't help you. The parameter that you think it will define the taborder just sets the z-order, meaning the order how controls are painted if they overlap. I'm not sure, but I think the tab-order is defined by the order how the controls are created.

下一次更新: 一种可能的解决方法是观察Tab键的键盘事件,然后获取活动控件并将焦点设置到接下来应该出现的控件上.

Next update: A possible workaround is to watch the keyboard-events for the Tab-key, then get the active control and set the focus to the control which should come next.

这篇关于在对话框上设置项目的选项卡顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆