Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How can I add controls into a tab control?

Posted on 1998-09-18
1
Medium Priority
?
181 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

604 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