CMFCReBar Class

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at CMFCReBar Class.

A CMFCReBar object is a control bar that provides layout, persistence, and state information for rebar controls.

Syntax

class CMFCReBar : public CPane  

Members

Public Methods

Name Description
CMFCReBar::AddBar Adds a band to a rebar.
CMFCReBar::CalcFixedLayout (Overrides CBasePane::CalcFixedLayout.)
CMFCReBar::CanFloat (Overrides CBasePane::CanFloat.)
CMFCReBar::Create Creates the rebar control and attaches it to the CMFCReBar object.
CMFCReBar::EnableDocking (Overrides CBasePane::EnableDocking.)
CMFCReBar::GetReBarBandInfoSize
CMFCReBar::GetReBarCtrl Provides direct access to the underlying CReBarCtrl common control.
CMFCReBar::OnShowControlBarMenu (Overrides CPane::OnShowControlBarMenu.)
CMFCReBar::OnToolHitTest (Overrides CWnd::OnToolHitTest.)
CMFCReBar::OnUpdateCmdUI (Overrides CBasePane::OnUpdateCmdUI.)
CMFCReBar::SetPaneAlignment (Overrides CBasePane::SetPaneAlignment.)

Remarks

A CMFCReBar object can contain a variety of child windows. This includes edit boxes, toolbars, and list boxes. You can resize the rebar programmatically, or the user can manually resize the rebar by dragging its gripper bar. You can also set the background of a rebar object to a bitmap of your choice.

A rebar object behaves similarly to a toolbar object. A rebar control can contain one or more bands, and each band can contain a gripper bar, a bitmap, a text label, and a child window.

Example

The following example demonstrates how to use various methods in the CMFCReBar class. The example shows how to create a rebar control and add a band to it. The band functions as an internal toolbar. This code snippet is part of the Rebar Test sample.

    CMFCReBar               m_wndReBar;
   // Each rebar pane will ocupy its own row:
    DWORD dwStyle = RBBS_GRIPPERALWAYS | RBBS_FIXEDBMP | RBBS_BREAK;
    // CMFCMenuBar m_wndMenuBar
    // CMFCToolBar m_wndToolBar
    if (!m_wndReBar.Create(this) ||
        !m_wndReBar.AddBar (&m_wndMenuBar) ||
        !m_wndReBar.AddBar (&m_wndToolBar, NULL, NULL, dwStyle))
    {
        TRACE0("Failed to create rebar\n");
        return -1;      // fail to create
    }

Inheritance Hierarchy

CObject CCmdTarget CWnd

CBasePane CPane CMFCReBar

Requirements

Header: afxRebar.h

CMFCReBar::AddBar

Adds a band to a rebar.

BOOL AddBar(
    CWnd* pBar,  
    LPCTSTR pszText = NULL,  
    CBitmap* pbmp = NULL,  
    DWORD dwStyle = RBBS_GRIPPERALWAYS | RBBS_FIXEDBMP);

BOOL AddBar(
    CWnd* pBar,  
    COLORREF clrFore,  
    COLORREF clrBack,  
    LPCTSTR pszText = NULL,  
    DWORD dwStyle = RBBS_GRIPPERALWAYS);

Parameters

[in] [out] pBar
A pointer to the child window that is to be inserted into the rebar. The referenced object must have the WS_CHILD window style.

[in] pszText
Specifies the text to appear on the rebar. The text is not part of the child window. Rather, it is displayed on the rebar itself.

[in] [out] pbmp
Specifies the bitmap to be displayed on the rebar background.

[in] dwStyle
Contains the style to apply to the band. For a complete list of band styles, see the description for fStyle in the REBARBANDINFO structure in the Windows SDK documentation.

[in] clrFore
Represents the foreground color of the rebar.

[in] clrBack
Represents the background color of the rebar.

Return Value

TRUE if the band was successfully added to the rebar; otherwise, FALSE.

CMFCReBar::Create

Creates the rebar control and attaches it to the CMFCReBar object.

BOOL Create(
    CWnd* pParentWnd,  
    DWORD dwCtrlStyle = RBS_BANDBORDERS,  
    DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_TOP,  
    UINT nID = AFX_IDW_REBAR);

Parameters

[in] [out] pParentWnd
A pointer to the parent window of this rebar control.

[in] dwCtrlStyle
Specifies the style for the rebar control. The default style value is RBS_BANDBORDERS, which displays narrow lines to separate adjacent bands on the rebar control. For a list of valid styles, see Rebar Control Styles in the Windows SDK documentation.

[in] dwStyle
The window style of the rebar control. For a list of valid styles, see Window Styles.

[in] nID
The rebar's child-window ID.

Return Value

TRUE if the rebar was created successfully; otherwise, FALSE.

Remarks

CMFCReBar::GetReBarCtrl

Provides direct access to CReBarCtrl the underlying common control for CMFCReBar objects.

CReBarCtrl& GetReBarCtrl() const;  

Return Value

A reference to the underlying CReBarCtrl object.

Remarks

Call this method to take advantage of the Windows rebar common control functionality when customizing your rebar.

CMFCReBar::CalcFixedLayout

This topic is included for completeness. For more detail see the source code located in the VC\atlmfc\src\mfc folder of your Visual Studio installation.

virtual CSize CalcFixedLayout(
    BOOL bStretch,  
    BOOL bHorz);

Parameters

[in] bStretch
[in] bHorz

Return Value

Remarks

CMFCReBar::CanFloat

This topic is included for completeness. For more detail see the source code located in the VC\atlmfc\src\mfc folder of your Visual Studio installation.

virtual BOOL CanFloat() const;  

Return Value

Remarks

CMFCReBar::EnableDocking

This topic is included for completeness. For more detail see the source code located in the VC\atlmfc\src\mfc folder of your Visual Studio installation.

void EnableDocking(DWORD dwDockStyle);

Parameters

[in] dwDockStyle

Remarks

CMFCReBar::GetReBarBandInfoSize

This topic is included for completeness. For more detail see the source code located in the VC\atlmfc\src\mfc folder of your Visual Studio installation.

UINT GetReBarBandInfoSize() const;  

Return Value

Remarks

CMFCReBar::OnShowControlBarMenu

This topic is included for completeness. For more detail see the source code located in the VC\atlmfc\src\mfc folder of your Visual Studio installation.

virtual BOOL OnShowControlBarMenu(CPoint);

Parameters

[in] CPoint

Return Value

Remarks

CMFCReBar::OnToolHitTest

This topic is included for completeness. For more detail see the source code located in the VC\atlmfc\src\mfc folder of your Visual Studio installation.

virtual INT_PTR OnToolHitTest(
    CPoint point,  
    TOOLINFO* pTI) const;  

Parameters

[in] point
[in] pTI

Return Value

Remarks

CMFCReBar::OnUpdateCmdUI

This topic is included for completeness. For more detail see the source code located in the VC\atlmfc\src\mfc folder of your Visual Studio installation.

virtual void OnUpdateCmdUI(
    CFrameWnd* pTarget,  
    BOOL bDisableIfNoHndler);

Parameters

[in] pTarget
[in] bDisableIfNoHndler

Remarks

CMFCReBar::SetPaneAlignment

This topic is included for completeness. For more detail see the source code located in the VC\atlmfc\src\mfc folder of your Visual Studio installation.

virtual void SetPaneAlignment(DWORD dwAlignment);

Parameters

[in] dwAlignment

Remarks

See Also

Hierarchy Chart
Classes
CReBarCtrl Class
CPane Class