将对话框组合到单个“组” (视觉工作室) [英] Group dialog items to a single "Group" (Visual Studio)

查看:205
本文介绍了将对话框组合到单个“组” (视觉工作室)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为应用程序的更改设置创建一个对话窗口。以下是Adobe Reader的屏幕截图。使用Spy ++后,我猜想:

I want to create a dialog window for change settings of an application. Below is a screenshot of Adobe Reader. After using Spy++, I guess that:

在右边,所有的控件(按钮,组合框等)都属于一个GroupBox。

对于左侧的TreeView控件中的每个类别,都有一个相应的GroupBox,用于对与此类别相关的所有控件进行分组。 / em>

For each category in the TreeView Control on the left side, there is a corresponding GroupBox which groups all the controls related to this category.

当用户在不同类别之间进行选择时,它会隐藏一个GroupBox,并显示另一个GroupBox。

但是在下面的源代码(xxx.rc,资源文件)中,我没有看到任何可以指定对话框项目的父的位置。

But in the source code (xxx.rc, resource file) below, I didn't see anywhere where I can specify the "parent" of a dialog item.

即使我打开xxx.rc与资源视图(不被视为代码),我找不到任何选项来指定对话项目的属性页面的父项。

Even I open xxx.rc with "Resource View" (not viewed as codes), I can't find any option to specify the parent of a dialog item in its property page.

我想知道如何在.rc文件中将一个父类(在我的情况下是一个GroupBox)分配给一个对话项,或将对话项分组到一个组,即一个创建对话项。 (我猜可以通过修改.rc文件来实现。)

I would like to know how to assign a parent (which is a GroupBox in my case) to a dialog item, or group dialog items to a single group,in the .rc file, i.e when one create the dialog items. (I guess one can do so by modifying the .rc file.)

GROUPBOX        "View",IDC_SECTION_VIEW,101,6,228,88
LTEXT           "Default &Layout:",IDC_DEFAULT_LAYOUT_LABEL,107,19,108,9
COMBOBOX        IDC_DEFAULT_LAYOUT,215,17,108,64,CBS_DROPDOWNLIST | WS_TABSTOP
LTEXT           "Default &Zoom:",IDC_DEFAULT_ZOOM_LABEL,107,36,108,9
COMBOBOX        IDC_DEFAULT_ZOOM,215,34,108,149,CBS_DROPDOWN | WS_TABSTOP
CONTROL         "Show the &bookmarks sidebar when available",IDC_DEFAULT_SHOW_TOC,
                "Button",BS_AUTOCHECKBOX | WS_TABSTOP,107,53,216,9
...
...
...

推荐答案


我想知道如何分配一个父母...

I would like to know how to assign a parent...

SetParent Windows API。您提供您的控件的 HWND 和假定的新父级的句柄。

SetParent Windows API. You supply HWND of your control and the handle of the supposed new parent.

在资源脚本中,控件将是对话框本身的孩子,但是在运行时你可以自由地改变它,并将它们分组成你感兴趣的层次结构。

In resource script, the controls will be children of the dialog itself, but on runtime you are free to change this and group them into a hierarchy of your interest.

你也可以考虑把孩子组成单独的对话框模板,并将其作为复合控件 - 被单独实例化,并成为较高级别对话框的子级。

You might also want to consider putting the supposed child groups into separate dialog template and have it as "composite control" - to be instantiated separately and be a child of a higher level dialog.

UPD。看看这个简单的项目(C ++ / ATL): AtlChildDialog 。特别是,在主对话框的WM_INITIDIALOG处理程序

UPD. Have a look at this simple project (C++/ATL): AtlChildDialog. In particular, at main dialog's WM_INITIDIALOG handler:

ATLVERIFY(m_ChildDialog.Create(m_hWnd, (LPARAM) this));
ATLVERIFY(m_ChildDialog.MoveWindow(50, 50, 200, 150));
m_ChildDialog.m_EditWindow.SetWindowText(_T("Some Text"));
m_ChildDialog.ShowWindow(SW_SHOWNORMAL);
m_ChildDialog.SetFocus();

运行时一起运行:

这篇关于将对话框组合到单个“组” (视觉工作室)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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