Share via


Rebar Controls and Bands

OverviewSample

The main purpose of a rebar control is to act as a container for child windows, common dialog controls, menus, toolbars, and so on. This containment is supported by the concept of a "band." Each rebar band can contain any combination of a gripper bar, a bitmap, a text label, and a child window.

Class CReBarCtrl has many member functions that you can use to retrieve, and manipulate, information for a specific rebar band:

  •    Retrieves the number of current bands in the rebar control.

  •    Initializes a REBARBANDINFO structure with information from the specified band. There is a corresponding member function.

  •    Retrieves the bounding rectangle of a specified band.

  •    Retrieves the number of band rows in a rebar control.

  •    Retrieves the index of a specified band.

  •    Retrieves the borders of a band.

In addition to manipulation, several member functions are provided that allow you to operate on specific rebar bands.

and add and remove rebar bands. and affect the current size of a specific rebar band. changes the index of a specific rebar band. shows or hides a rebar band from the user.

The following example demonstrates adding a toolbar band (m_wndToolBar) to an existing rebar control (m_wndReBar). The band is described by initializing the rbi structure and then calling the InsertBand member function:

//load bitmap for toolbar background
m_bmap.LoadBitmap(IDB_BITMAP);

//create a toolbar band
m_wndToolBar.Create(this, TBSTYLE_TRANSPARENT | TBSTYLE_FLAT);
m_wndToolBar.LoadToolBar(IDR_MAINFRAME);

REBARBANDINFO rbi;
rbi.cbSize= sizeof(REBARBANDINFO);
rbi.fMask= RBBIM_BACKGROUND | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_STYLE | RBBIM_TEXT;
rbi.fStyle= RBBS_GRIPPERALWAYS;
rbi.cxMinChild= 300;
rbi.cyMinChild= 30;
rbi.lpText= "Band #1";
rbi.cch= 7;
rbi.cx= 300;
rbi.hbmBack= (HBITMAP)m_bmap;
rbi.hwndChild= (HWND)m_wndToolBar;
m_wndReBar.InsertBand(-1, &rbi);

See Also   Windows Common Controls and MFC Classes