CReBar

Win32++

CReBar Class

Description

The class responsible for creating a ReBar control.  ReBar controls act as containers for child windows.  An application assigns child windows, which are often other controls, to a rebar control band.  ReBar controls contain one or more bands, and each band can have any combination of a gripper bar, a bitmap, a text label, and a child window.

Refer to the documentation that ships with the Microsoft Windows Software Development Kit for more information on the use of rebar controls.

CReBar Members

CReBar
CReBar();
Constructor for CReBar.
DeleteBand
BOOL DeleteBand(const int nBand) const;
Deletes a band from the rebar control. GetBand
int GetBand(const HWND hWnd) const;
Returns the band number given the band's window handle. GetBandBorders
CRect GetBandBorders(int nBand) const;
Retrieves the borders of a band. The result of this message can be used to calculate the usable area in a band. GetBandCount
int GetBandCount() const;
Retrieves the count of bands currently in the rebar control. GetBandInfo
BOOL GetBandInfo(const int nBand, REBARBANDINFO& rbbi) const;
Retrieves information about a specified band in a rebar control. GetBandRect
CRect GetBandRect(int i) const;
Retrieves the bounding rectangle for a given band in a rebar control. GetBarHeight
UINT GetBarHeight() const;
Retrieves the height of the rebar control. GetRowCount
UINT GetRowCount() const;
Retrieves the number of rows of bands in a rebar control. GetRowHeight
int GetRowHeight(int nRow) const;
Retrieves the height of a specified row in a rebar control. GetSizeofRBBI
UINT GetSizeofRBBI() const;
Returns the correct value for sizeof(REBARBANDINFO). GetToolTips
CToolTip* GetToolTips() const;
Retrieves the handle to any ToolTip control associated with the rebar control. HitTest
int HitTest(RBHITTESTINFO& rbht);
HWND HitTest(POINT pt);
Determines which portion of a rebar band is at a given point on the screen, if a rebar band exists at that point. IDToIndex
int IDToIndex(UINT uBandID) const;
Converts a band identifier to a band index in a rebar control. InsertBand
BOOL InsertBand(const int nBand, REBARBANDINFO& rbbi) const;
Inserts a new band in a rebar control. IsBandVisible
BOOL IsBandVisible(int nBand) const;
Returns TRUE if band is visible, otherwise FALSE MaximizeBand
void MaximizeBand(UINT uBand, BOOL fIdeal = FALSE);
Resizes a band in a rebar control to either its ideal or largest size. MinimizeBand
void MinimizeBand(UINT uBand);
Resizes a band in a rebar control to its smallest size. MoveBand
BOOL MoveBand(UINT uFrom, UINT uTo);
Moves a band from one index to another. MoveBandsLeft
void MoveBandsLeft();
Repositions the bands so that they are moved to the left. ResizeBand
BOOL ResizeBand(const int nBand, const CSize& sz) const;
Changes the size of a rebar band. SetBandBitmap
BOOL SetBandBitmap(const int nBand, const HBITMAP hBackground) const;
Sets a bitmap to the ReBar control SetBandColor
BOOL SetBandColor(const int nBand, const COLORREF clrFore,
                  const COLORREF clrBack) const;
Sets the colour of a ReBar band SetBandInfo
BOOL SetBandInfo(const int nBand, REBARBANDINFO& rbbi) const;
Sets characteristics of an existing band in the rebar control. SetBarInfo
BOOL SetBarInfo(REBARINFO& rbi) const;
Sets the characteristics of a rebar control. ShowBand
BOOL ShowGripper(int nBand, BOOL fShow) const;
Shows or hides a band ShowGripper
BOOL ShowBand(int nBand, BOOL fShow) const;
Shows or hides a band's gripper. SizeToRect
BOOL SizeToRect(CRect& rect) const;
Finds the best layout of the bands from the given rectangle.
Base class Members

For base class members, refer to the members of CWnd.

Remarks

Like all common controls, the rebar control requires a parent window. This parent window is often a dialog, but simple windows can also be the parent window for a rebar control.

The following code creates a ComboBox and adds it to the rebar.

void CMainFrame::AddListboxBand(int Listbox_Height)
{
  // Get the reference to the rebar object
  CReBar& RB = GetReBar();
  ThemeReBar RBTheme = RB.GetReBarTheme();

  // Create the ComboboxEx window
  CREATESTRUCT cs = {0};
  cs.lpszClass = _T("COMBOBOXEX32");
  cs.style = WS_VISIBLE | WS_CHILD | CBS_DROPDOWN;
  cs.cy = 100;	// required to display list
  cs.hMenu = (HMENU)IDC_COMBOBOXEX;
  m_ComboboxEx.PreCreate(cs);
  m_ComboboxEx.Create(GetReBar().GetHwnd());

  // Put the window in a new rebar band
  REBARBANDINFO rbbi = {0};
  rbbi.cbSize     = GetSizeofRBBI();
  rbbi.fMask      = RBBIM_COLORS | RBBIM_CHILDSIZE | RBBIM_STYLE | RBBIM_CHILD | RBBIM_TEXT;
  rbbi.cyMinChild = Listbox_Height;
  rbbi.cyMaxChild = Listbox_Height;
  rbbi.cxMinChild = 200;
  rbbi.fStyle     = RBBS_BREAK | RBBS_VARIABLEHEIGHT | RBBS_GRIPPERALWAYS;
  rbbi.clrFore    = GetSysColor(COLOR_BTNTEXT);
  rbbi.clrBack    = RBTheme.clrBand1;
  rbbi.hwndChild  = m_ComboboxEx.GetHwnd();
  rbbi.lpText     = _T("Address");

  RB.InsertBand(-1, rbbi);
}

CRebar is used by CFrame to contain a CMenuBar and a CToolBar.

Summary Information

Header file rebar.h
Win32/64 support Yes
WinCE support Yes
Library required Comctl32.lib