Edit

Share via


CMFCReBar Class

A CMFCReBar object is a control bar that provides layout, persistence, and state information for rebar controls. For more detail see the source code located in the VC\atlmfc\src\mfc folder of your Visual Studio installation.

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

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

pszText
[in] 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.

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

dwStyle
[in] 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.

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

clrBack
[in] 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

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

dwCtrlStyle
[in] 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.

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

nID
[in] 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

virtual CSize CalcFixedLayout(
    BOOL bStretch,
    BOOL bHorz);

Parameters

[in] bStretch
[in] bHorz

Return Value

Remarks

CMFCReBar::CanFloat

virtual BOOL CanFloat() const;

Return Value

Remarks

CMFCReBar::EnableDocking

void EnableDocking(DWORD dwDockStyle);

Parameters

[in] dwDockStyle

Remarks

CMFCReBar::GetReBarBandInfoSize

UINT GetReBarBandInfoSize() const;

Return Value

Remarks

CMFCReBar::OnShowControlBarMenu

virtual BOOL OnShowControlBarMenu(CPoint);

Parameters

[in] CPoint

Return Value

Remarks

CMFCReBar::OnToolHitTest

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

Parameters

[in] point
[in] pTI

Return Value

Remarks

CMFCReBar::OnUpdateCmdUI

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

Parameters

[in] pTarget
[in] bDisableIfNoHndler

Remarks

CMFCReBar::SetPaneAlignment

virtual void SetPaneAlignment(DWORD dwAlignment);

Parameters

[in] dwAlignment

Remarks

See also

Hierarchy Chart
Classes
CReBarCtrl Class
CPane Class