?
Solved

How can I add controls into a tab control?

Posted on 1998-09-18
1
Medium Priority
?
179 Views
Last Modified: 2013-11-19
I would like to add controls inside a tab control, preferably using the resource editor. How must it be done?

Thanks in advance
fug
0
Comment
Question by:fug
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
girts063098 earned 280 total points
ID: 1322263
At first, in VC++ manipulate with TabCtrl is not so easy as in VB. In VC objects in TabCtrl are not grouped. It means every object must be set visible or not seperatly.
Here is example how to do it:
(In parenthesis I put the names I used in Example.)
At first you must create TabCtrl(IDC_TAB2) and some objects(IDC_BUTTON3, IDC_BUTTON4, IDC_BUTTON5, IDC_BUTTON6) in Dialog Box.
Then add a member variable to TabCtrl(m_Tab).
Then you must add some initial lines in OnInitialUpdate method in View class:

  TC_ITEM MyTab;
  MyTab.mask = TCIF_TEXT;

  MyTab.pszText = "Selection 1";
  m_Tab.InsertItem(0, &MyTab);

  MyTab.pszText = "Text";
  m_Tab.InsertItem(1, &MyTab);

  MyTab.pszText = "Hmmm...";
  m_Tab.InsertItem(2, &MyTab);

This will create three tabs named: Selection1, Text, Hmmm...

Then you must override ON_IDC_TAB2:TCN_SELCHANGE - OnSelchangeTab:

  int Item0[] = {IDC_BUTTON3, 0};
  int Item1[] = {IDC_BUTTON4, 0};
  int Item2[] = {IDC_BUTTON5, IDC_BUTTON6, 0};
  int * Items[] = {Item0, Item1, Item2, 0 };
  int * pItem, **pItems;
  int nSel = m_Tab.GetCurSel();
  CWnd * pWnd;
  for (pItems = (int **)Items; *pItems; *pItems++)
  for (pItem = *pItems; *pItem; pItem++)
  {
    pWnd = GetDlgItem(*pItem);
    pWnd->ShowWindow(SW_HIDE);
  }
  for (pItem = Items[nSel]; *pItem; pItem++)
  {
    pWnd = GetDlgItem(*pItem);
    pWnd->ShowWindow(SW_SHOW);
  }
Theese lines will make visible objects you have listed in
Item0[] and will make invisible all others.
Item0[], Item1[], etc. contain objects that must be visible in each TabCtrl selection. If you have more than three tabs then just make new variables Item3[], Item4[] etc. and list them in *Items[];

That's all.

Girts.

0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month9 days, 12 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question