如何向 Tab 控件添加控件
我在 GUI 应用程序中使用选项卡控件,并且我知道如何从中添加和删除选项卡(TCM_INSERTITEM 等),但我不知道如何向选项卡添加其他控件,如按钮等。如何添加控件到一个选项卡? (注意,我不是PropertySheet控件,而是Tab控件。)
I am using a Tab control in my GUI app and I know how to add and remove tabs from it (TCM_INSERTITEM, etc.) but I cannot figure out how to add other controls to a tab like Buttons, etc. How do you add controls to a tab? (Note that I am not a PropertySheet control, but a Tab control.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您正在谈论向选项卡控件的主体添加控件:您不会。
您要做的就是为每个选项卡创建一个子样式的对话框控件,其中将包含该选项卡的控件。选择每个选项卡后,您可以处理来自选项卡控件的通知以创建并显示适当的页面控件。页面对话框通常是选项卡控件的父级的父级,而不是选项卡控件本身。
If you are talking about adding controls to the body of the tab control: You don't.
What you do is create a child styled dialog control for each tab, which will have the controls for that tab on it. As each tab is selected, you handle the notification from the tab control to create and show the appropriate page control. The page dialogs are normally parented to the parent of the tab control, not the tab control itself.
虽然您当然可以将选项卡控件指定为另一个控件的父级,但这对您没有帮助。选项卡控件不会意识到它的(新添加的)子控件,因此它无法自行安排以容纳它们。
所以简短的回答是:你不能。
长的答案是您有两个选择:
1)构建您自己的可以支持子项的选项卡控件。
2) 将其他控件与选项卡控件一起排列,使它们能够组合在一起,但不重叠。
While you can certainly specify a tab control as the parent of another control, this isn't going to help you. The tab control will not be aware of its (newly added) children and so it cannot arrange itself to accomodate them.
So the short answer is: You cannot.
The long answer is that you have two choices:
1) Build your own tab control which can support children.
2) Arrange the other controls along with the tab control such that they fit together, but do not overlap.