将对话项分组到单个“组"中.(视觉工作室) [英] Group dialog items to a single "Group" (Visual Studio)
问题描述
我想创建一个对话窗口来更改应用程序的设置.下面是 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,将与该类别相关的所有控件分组.
当用户在不同的类别之间进行选择时,它会隐藏一个 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屋!