Partager via


Rebar Controls and Bands

 

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 Rebar Controls and Bands.

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:

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

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

  • GetRect Retrieves the bounding rectangle of a specified band.

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

  • IDToIndex Retrieves the index of a specified band.

  • GetBandBorders Retrieves the borders of a band.

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

InsertBand and DeleteBand add and remove rebar bands. MinimizeBand and MaximizeBand affect the current size of a specific rebar band. MoveBand changes the index of a specific rebar band. ShowBand 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_RebarBitmap.LoadBitmap(IDB_BITMAP1);

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

      REBARBANDINFO rbi = {0};
      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 = 50;
      rbi.lpText = _T("Band #1");
      rbi.cch = 7;
      rbi.cx = 300;
      rbi.hbmBack = (HBITMAP)m_RebarBitmap;
      rbi.hwndChild = (HWND)m_Toolbar1;
      m_Rebar.GetReBarCtrl().InsertBand(0, &rbi);

See Also

Using CReBarCtrl
Controls