Click here to Skip to main content
Licence CPOL
First Posted 4 Jun 2004
Views 105,222
Bookmarked 46 times

TabedReBar Control

By | 4 Jun 2004 | Article
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)

About the Author

Bahrudin Hrnjica

Software Developer

Bosnia And Herzegovina Bosnia And Herzegovina

Member

Senior Software Developer and Microsoft MVP 2011 for Visual C#.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionTCN_SELCHANGE notification message in VC9 PinmemberElaaber10:47 30 Aug '10  
AnswerRe: TCN_SELCHANGE notification message in VC9 Pinmemberkerfall2:35 4 Jul '11  
GeneralNice work! PinmemberRambo lin2:56 15 Apr '09  
GeneralVery Nice ! Thanks :> Pinmemberpyrokar9:32 25 Dec '04  
GeneralRe: Very Nice ! Thanks :> PinmemberBahrudin Hrnjica20:06 13 Apr '05  
JokeRe: Very Nice ! Thanks :> PinmemberWooTao1:12 21 Apr '06  
GeneralI found a bad bug PinmemberSchniddel8:56 17 Dec '04  
GeneralRe: I found a bad bug PinmemberBahrudin Hrnjica0:27 29 Dec '04  
GeneralRe: I found a bad bug PinmemberSchniddel0:44 29 Dec '04  
GeneralRe: I found a bad bug PinmemberBahrudin Hrnjica21:26 29 Dec '04  
GeneralRe: I found a bad bug PinmemberSchniddel1:23 30 Dec '04  
GeneralThe Width is too long PinmemberSchniddel2:52 11 Dec '04  
GeneralRe: The Width is too long PinmemberBahrudin Hrnjica9:22 12 Dec '04  
GeneralBad, ugly control, that died a long time ago Pinmemberarmentage5:20 10 Jun '04  
GeneralRe: Bad, ugly control, that died a long time ago PinmemberBahrudin Hrnjica8:01 10 Jun '04  
GeneralRe: Bad, ugly control, that died a long time ago Pinmemberarmentage8:27 10 Jun '04  
GeneralRe: Bad, ugly control, that died a long time ago PinmemberJ Morgan1:22 11 Jun '04  
GeneralRe: Bad, ugly control, that died a long time ago Pinsussc'mon20:08 11 Jun '04  
GeneralRe: Bad, ugly control, that died a long time ago PinmemberBahrudin Hrnjica8:34 12 Jun '04  
GeneralRe: Bad, ugly control, that died a long time ago Pinmemberarmentage3:34 14 Jun '04  
GeneralRe: Bad, ugly control, that died a long time ago PinmemberBahrudin Hrnjica11:01 14 Jun '04  
GeneralRe: Bad, ugly control, that died a long time ago - NOT PinmemberEd K6:23 9 Mar '06  
GeneralRe: Bad, ugly control, that died a long time ago Pinmembera_b_pathak23:07 17 Jun '07  
GeneralRe: Bad, ugly control, that died a long time ago PinmemberSpanKie6:26 13 Jun '08  
GeneralRe: Bad, ugly control, that died a long time ago PinmemberHockey9:19 28 Jul '04  

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.

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