Click here to Skip to main content
11,714,345 members (82,236 online)
Click here to Skip to main content

TabedReBar Control

, 4 Jun 2004 CPOL 118.6K 3.8K 50
Rate this:
Please Sign up or sign in to vote.
ReBar control which displays bars via tab panes.

Sample Image - TabedReBar.jpg

Overview

This article implements TabedReBar control similar to CReBar which displays bars via Tab control. The main propose of the TabedReBar control is reducing space of the MainFrame window by collecting several bars in one TabedReBar. Each bar (ToolBar, StatusBar, DialogBar etc.) added in TabedReBar is separated by a Tab.

Class CBHTabedReBar

The CBHTabedReBar is derived from CControlBar and contains the following methods and data members:

Methods

void DrawGripper(CDC* pDC); //Draws griper on left side of the control
BOOL AddBar(CControlBar*pBar,LPCTSTR pszText = NULL);//Add Bars to TabedReBar
CTabCtrl& GetTabCtrl() const; // access the tab control

//{{AFX_MSG(CBHTabedReBar)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnTabSelChange(NMHDR* pNMHDR, LRESULT* pResult) ;
afx_msg void OnWindowPosChanged(WINDOWPOS* lpwndpos);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
//}}AFX_MSG

//{{AFX_VIRTUAL(CBHTabedReBar)
virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
virtual BOOL Create( CWnd* pParentWnd,
                           DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_TOP,
                           UINT nID = AFX_IDW_TABED_REBAR);
virtual CSize CalcFixedLayout( BOOL bStretch, BOOL bHorz );
virtual void DoPaint(CDC* pDC); // overriden virtual member
//{{AFX_VIRTUAL

Members

int                            m_nToobBarHeight;//height of tab

int                            m_nActiveTab; // currently active tab

CRect                          m_rectClient; // rect of the tab control

CList <TCB_ITEM *,TCB_ITEM *>  m_Bars; // list of derived ControlBars

CTabCtrl                       m_tabctrl; // Tab Control

Implementation

CBHTabedReBar class supports docking (top, bottom from now) and floating features. Define CBHTabedReBar class object on the same way as you define CReBar.

In MainFrm.h, declare variable CBHTabedReBar:

CBHTabedReBar m_wndTabedReBar;

In MainFrm.cpp, in OnCreate message member after creation of ToolBars, DialogBar etc., add code similar to this:

int CMainFrame:: OnCreate(LPCREATESTRUCT lpCreateStruct)
{
//................
//Here comes standard creation code
//Creation code for CBHTabedReBar control


m_wndTabedReBar.Create(this);
m_wndTabedReBar.SetWindowText("Tabed ReBar");
m_wndTabedReBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
                            CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

//Adding Bars to TabedReBar control
m_wndTabedReBar.AddBar(&m_wndToolBar1,"Standard Toolbar");
m_wndTabedReBar.AddBar(&m_wndExplererToolBar,"Explorer Toolbar");
//Adding Icons to Tab Control

m_images.Create(IDB_TABIMAGES, 16, 1, RGB(255,0,255));
m_wndTabedReBar.GetTabCtrl().SetImageList(&m_images);
}

Update History

  • 1.0.0.109 June 5. 2004, First release version.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Bahrudin Hrnjica
Software Developer (Senior)
Bosnia And Herzegovina Bosnia And Herzegovina
Senior Software Developer at daenet.eu and Microsoft MVP for Visual C#.

You may also be interested in...

Comments and Discussions

 
QuestionTCN_SELCHANGE notification message in VC9 Pin
Elaaber30-Aug-10 10:47
memberElaaber30-Aug-10 10:47 
AnswerRe: TCN_SELCHANGE notification message in VC9 Pin
kerfall4-Jul-11 2:35
memberkerfall4-Jul-11 2:35 
GeneralNice work! Pin
Rambo lin15-Apr-09 2:56
memberRambo lin15-Apr-09 2:56 
GeneralVery Nice ! Thanks :&gt; Pin
pyrokar25-Dec-04 9:32
memberpyrokar25-Dec-04 9:32 
GeneralRe: Very Nice ! Thanks :&gt; Pin
Bahrudin Hrnjica13-Apr-05 20:06
memberBahrudin Hrnjica13-Apr-05 20:06 
JokeRe: Very Nice ! Thanks :&gt; Pin
WooTao21-Apr-06 1:12
memberWooTao21-Apr-06 1:12 
GeneralI found a bad bug Pin
Schniddel17-Dec-04 8:56
memberSchniddel17-Dec-04 8:56 
GeneralRe: I found a bad bug Pin
Bahrudin Hrnjica29-Dec-04 0:27
memberBahrudin Hrnjica29-Dec-04 0:27 
GeneralRe: I found a bad bug Pin
Schniddel29-Dec-04 0:44
memberSchniddel29-Dec-04 0:44 
GeneralRe: I found a bad bug Pin
Bahrudin Hrnjica29-Dec-04 21:26
memberBahrudin Hrnjica29-Dec-04 21:26 
GeneralRe: I found a bad bug Pin
Schniddel30-Dec-04 1:23
memberSchniddel30-Dec-04 1:23 
GeneralThe Width is too long Pin
Schniddel11-Dec-04 2:52
memberSchniddel11-Dec-04 2:52 
GeneralRe: The Width is too long Pin
Bahrudin Hrnjica12-Dec-04 9:22
memberBahrudin Hrnjica12-Dec-04 9:22 
GeneralBad, ugly control, that died a long time ago Pin
armentage10-Jun-04 5:20
memberarmentage10-Jun-04 5:20 
GeneralRe: Bad, ugly control, that died a long time ago Pin
Bahrudin Hrnjica10-Jun-04 8:01
memberBahrudin Hrnjica10-Jun-04 8:01 
GeneralRe: Bad, ugly control, that died a long time ago Pin
armentage10-Jun-04 8:27
memberarmentage10-Jun-04 8:27 
GeneralRe: Bad, ugly control, that died a long time ago Pin
J Morgan11-Jun-04 1:22
memberJ Morgan11-Jun-04 1:22 
GeneralRe: Bad, ugly control, that died a long time ago Pin
c'mon11-Jun-04 20:08
sussc'mon11-Jun-04 20:08 
GeneralRe: Bad, ugly control, that died a long time ago Pin
Bahrudin Hrnjica12-Jun-04 8:34
memberBahrudin Hrnjica12-Jun-04 8:34 
GeneralRe: Bad, ugly control, that died a long time ago Pin
armentage14-Jun-04 3:34
memberarmentage14-Jun-04 3:34 
GeneralRe: Bad, ugly control, that died a long time ago Pin
Bahrudin Hrnjica14-Jun-04 11:01
memberBahrudin Hrnjica14-Jun-04 11:01 
GeneralRe: Bad, ugly control, that died a long time ago - NOT Pin
Ed K9-Mar-06 6:23
memberEd K9-Mar-06 6:23 
GeneralRe: Bad, ugly control, that died a long time ago Pin
a_b_pathak17-Jun-07 23:07
membera_b_pathak17-Jun-07 23:07 
GeneralRe: Bad, ugly control, that died a long time ago Pin
SpanKie13-Jun-08 6:26
memberSpanKie13-Jun-08 6:26 
GeneralRe: Bad, ugly control, that died a long time ago Pin
Hockey28-Jul-04 9:19
memberHockey28-Jul-04 9:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150819.1 | Last Updated 5 Jun 2004
Article Copyright 2004 by Bahrudin Hrnjica
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid