Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a control to a tab control

Status
Not open for further replies.

REWT

Programmer
Aug 10, 2001
12
US
How do I add a listview or treeview control to a tab control. I have not been able to drag and drop to add a control to the tabs I placed on my dialog. Every other language has supported dropping controls onto other controls to ease the GUI making process. Is this not possible with Visual C++? If anyone has and code examples or places where I can get some good examples I would be most appreciative. Thanks in advance.

REWT
 
Yes. You should place the ListView or TreeView in the tab control as you post it in a dialog. Don't forget what you need for it comctl32.lib ir you are not using MFC. In the same case you should write some more code for initialize it. John Fill
1c.bmp


ivfmd@mail.md
 
Don't forget to associate the tab-control's pages with a dialog. the tab-control itself cannot hold other controls.
 
So I have to make some property pages and associate one property page with each tab in the tab control? How can I do this? I can make property pages with the ATL object. And then add controls to them. How do I get the property pages into the tab control. An example would be helpful. I have not found any good examples in the books I have. If anyone has a good recommendation for a VC++ book, that would be nice too. Thanks again.

REWT
 
which "tab"-control are you speaking of ?
if it's the one you include to your project via the
"project"-menue item you might be in trouble, 'cause these
Active-X controls work pretty easy with VB but not with
VC.
 
The tab control I am trying to use the the default one in the control menu after creating a new MFC(.exe) project. I cant seem to find examples of how to use it. And I cant drag and drop components onto it. I have noticed that some activeX things work much nicer in VB so I try to stay away from them unless necessary.

REWT
 
if you use this it's rather easy.

TC_ITEM TabItem;
TabItem.mask = TCIF_TEXT;

TabItem.pszText = "how the tab is called";
m_ctrlUserTab.InsertItem(0, &TabItem);

CTabDlg1* pUserTab1;
pUserTab1 = new CTabDlg1();

TabItem.mask = TCIF_PARAM;
TabItem.lParam = (LPARAM) pUserTab1;
m_ctrlUserTab.SetItem(0, &TabItem);
VERIFY(pUserTab1->Create(IDD_TAB_DLG1, &m_ctrlUserTab));
pUserTab1->SetWindowPos(NULL,10,30,0,0, SWP_NOSIZE | SWP_NOZORDER);
pUserTab1->ShowWindow(SW_SHOW);

with the tab control create m_ctrlUserTab (or any other name).
with the dialog you want to associate with the tab create class CTabDlg1.
for multiple tabs do this repeatedly.

hope this helps

 
The code that you gave me crashes the program when I try to set the window position and / or show the window. The error that I get is an assertion error which I have never heard of before. I also had to comment out the VERIFY statement because the compiler said it did not recieve the proper number of arguments. Should the Items added to the tabs be property pages? That is what I am trying to use. Any ideas on why the program would generate an asserion error and fail? Thanks again.

REWT
 
I do not clearly know what you with "property page".
The dialog you connect to the tab is a regular dialog box
(IDD_TAB_DLG1).
The "Zero" in InsertItem and SetItem refers to the tab-number.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top