How to add controls to a Tab control

穿精又带淫゛_ 提交于 2019-12-01 05:32:24

问题


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.)


回答1:


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.




回答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.



来源:https://stackoverflow.com/questions/4701974/how-to-add-controls-to-a-tab-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!