在Win32对话框中如何以编程方式更改标签顺序? [英] How do you programmatically change the tab order in a Win32 dialog?

查看:137
本文介绍了在Win32对话框中如何以编程方式更改标签顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,在通过对话框模板和CreateDialogIndirect生成对话框之后,通常需要在对话框中添加一个控件。在这些情况下,选项卡顺序由对话框模板设置,并且没有明显的方法通过添加新创建的控件来更改选项卡顺序。

解决方案

我最近发现可以使用SetWindowPos来实现这一点。确定哪个控件,然后在Tab按钮中插入新控件,然后使用SetWindowPos,如下所示:

  SetWindowPos(hNewControl, hOldControl,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE); 

这会更改控件的z顺序,反过来又会建立标签顺序。


Often time I need to add a control to a dialog after the dialog has been generated via dialog template and CreateDialogIndirect. In these cases the tab order is set by the dialog template and there is no obvious way to change the tab order by including a newly created control.

解决方案

I recently discovered that you can use SetWindowPos to accomplish this. Determine which control after which you want to insert the new control in the tab order then use SetWindowPos like this:

SetWindowPos(hNewControl, hOldControl, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); 

This changes the z-order of controls which, in turn, establishes the tab order.

这篇关于在Win32对话框中如何以编程方式更改标签顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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