Click here to Skip to main content
15,867,771 members
Articles / Desktop Programming / MFC
Article

TabedReBar Control

Rate me:
Please Sign up or sign in to vote.
4.69/5 (13 votes)
4 Jun 2004CPOL 148.6K   4.4K   50   30
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)


Written By
Software Developer (Senior)
Bosnia and Herzegovina Bosnia and Herzegovina
Bahrudin Hrnjica holds a Ph.D. degree in Technical Science/Engineering from University in Bihać.
Besides teaching at University, he is in the software industry for more than two decades, focusing on development technologies e.g. .NET, Visual Studio, Desktop/Web/Cloud solutions.

He works on the development and application of different ML algorithms. In the development of ML-oriented solutions and modeling, he has more than 10 years of experience. His field of interest is also the development of predictive models with the ML.NET and Keras, but also actively develop two ML-based .NET open source projects: GPdotNET-genetic programming tool and ANNdotNET - deep learning tool on .NET platform. He works in multidisciplinary teams with the mission of optimizing and selecting the ML algorithms to build ML models.

He is the author of several books, and many online articles, writes a blog at http://bhrnjica.net, regularly holds lectures at local and regional conferences, User groups and Code Camp gatherings, and is also the founder of the Bihac Developer Meetup Group. Microsoft recognizes his work and awarded him with the prestigious Microsoft MVP title for the first time in 2011, which he still holds today.

Comments and Discussions

 
GeneralRe: Bad, ugly control, that died a long time ago Pin
Abhijeet Pathak17-Jun-07 23:07
Abhijeet Pathak17-Jun-07 23:07 
GeneralRe: Bad, ugly control, that died a long time ago Pin
SpanKie13-Jun-08 6:26
SpanKie13-Jun-08 6:26 
GeneralRe: Bad, ugly control, that died a long time ago Pin
alex.barylski28-Jul-04 9:19
alex.barylski28-Jul-04 9:19 
GeneralRe: Bad, ugly control, that died a long time ago Pin
Mercede8-Sep-09 8:37
Mercede8-Sep-09 8:37 
GeneralGood Job, Jarane Pin
Amer Gerzic10-Jun-04 2:58
Amer Gerzic10-Jun-04 2:58 
GeneralRe: Good Job, Jarane Pin
Bahrudin Hrnjica10-Jun-04 8:03
professionalBahrudin Hrnjica10-Jun-04 8:03 
GeneralMissing file. Pin
WREY5-Jun-04 19:59
WREY5-Jun-04 19:59 
GeneralRe: Missing file. Pin
Bahrudin Hrnjica6-Jun-04 0:31
professionalBahrudin Hrnjica6-Jun-04 0:31 
afximpl.h is in sepecific location which depends which version of Visual Studio you are using.

..\Microsoft Visual Studio .NET\Vc7\atlmfc\src\mfc\afximpl.h for VC NET 2002


..\Microsoft Visual Studio\VC98\MFC\SRC\AFXIMPL.H for VC 6

Visual Studio 6:
To include the file go to Tools->Option->directories

Visual Studio NET 2002
Tools->Option->Project->VC++ Directories

From ComboBox (Show directories for) select Include Files

Add the file to standard include files list

regards

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

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