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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need info about CTabCtrl

Status
Not open for further replies.

BobbyB

Programmer
Feb 19, 2002
44
CA
I've tried to use the CTabCtrl class just to found that it is unacceptable... I've also tried some derived class created by some others just to found that they also are lacking...

If you can give me some advices on "your" best way to use this control it would be of great help.

thanks.
 
CTabCtrl wrap around the Windows tab control which is not a container like the one in Access. In Access, the tab control is a container that can use to contain other controls. In Windows programming, you have to provide all these container functionality in the code.

For complex design, you might want to use property sheet/property page instead.

Shyan
 
Hi

Well, it depends what you mean by unacceptable ...

It is in fact quite powerfull and you can do a lot of things with it.

In fact, You can add dialog box for every tab very easily.

Like this:

First egt a pointer to the TabCtrl

CWnd* pWndTab = ( CWnd*) GetDlgItem( IDC_DATA_TAB);

Then add the dialogboxes:

// Create Child Dialog Boxes

m_LogDlg.Create( IDD_LOG_DLG, pWndTab);
m_NewLogDlg.Create( IDD_NEW_LOG_DLG, pWndTab);

Then insert Item in TabCtrl:

TCITEM tc = {0};

tc.cchTextMax = strlen( "Log");
tc.pszText = "Log";
tc. mask = TCIF_TEXT | TCIF_PARAM;
tc.lParam= &m_LogDlg;
InsertItem( 0, &tc);

Then you handle the OnSelChange to show/hide the dialog boxes:
I assumed that you maintain a member called m_nCurSel that stored the current tab index ...

// Hide Current Selection

TCITEM tc;
tc.mask = TCIF_PARAM ;
GetItem( m_nCurSel, &tc);
CWnd* pWnd = (CWnd*) tc.lParam;
HWND hwnd = pWnd->GetSafeHwnd();
::ShowWindow( hwnd, SW_HIDE);

m_nPrevSel = m_nCurSel;

// Get Current Selection
m_nCurSel = GetCurSel();

// Get Pointer to Window
tc.mask = TCIF_PARAM ;
GetItem( m_nCurSel, &tc);
pWnd = (CWnd*) tc.lParam;
hwnd = pWnd->GetSafeHwnd();
::ShowWindow( hwnd, SW_SHOW);

Here you see the interest of storing the address of the dialogbox in the param member of the TCITEM structure.

It's just a small exemple that show that you can do almost what you want. You can also enable/disable the tas, change the background color, the text color, ...

Good luck

Thierry
EMail: Thierry.Marneffe@swing.be

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top