description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Learn more about: CReBarCtrl Class |
CReBarCtrl Class |
11/19/2018 |
|
|
154570d7-e48c-425d-8c7e-c64542bcb4cc |
Encapsulates the functionality of a rebar control, which is a container for a child window.
class CReBarCtrl : public CWnd
Name | Description |
---|---|
CReBarCtrl::CReBarCtrl | Constructs a CReBarCtrl object. |
Name | Description |
---|---|
CReBarCtrl::BeginDrag | Places the rebar control into drag-and-drop mode. |
CReBarCtrl::Create | Creates the rebar control and attaches it to the CReBarCtrl object. |
CReBarCtrl::CreateEx | Creates a rebar control with the specified Windows extended styles and attaches it to a CReBarCtrl object. |
CReBarCtrl::DeleteBand | Deletes a band from a rebar control. |
CReBarCtrl::DragMove | Updates the drag position in the rebar control after a call to BeginDrag . |
CReBarCtrl::EndDrag | Terminates the rebar control's drag-and-drop operation. |
CReBarCtrl::GetBandBorders | Retrieves the borders of a band. |
CReBarCtrl::GetBandCount | Retrieves the count of bands currently in the rebar control. |
CReBarCtrl::GetBandInfo | Retrieves information about a specified band in a rebar control. |
CReBarCtrl::GetBandMargins | Retrieves the margins of a band. |
CReBarCtrl::GetBarHeight | Retrieves the height of the rebar control. |
CReBarCtrl::GetBarInfo | Retrieves information about the rebar control and the image list it uses. |
CReBarCtrl::GetBkColor | Retrieves a rebar control's default background color. |
CReBarCtrl::GetColorScheme | Retrieves the COLORSCHEME structure associated with the rebar control. |
CReBarCtrl::GetDropTarget | Retrieves a rebar control's IDropTarget interface pointer. |
CReBarCtrl::GetExtendedStyle | Gets the extended style of the current rebar control. |
CReBarCtrl::GetImageList | Retrieves the image list associated with a rebar control. |
CReBarCtrl::GetPalette | Retrieves the rebar control's current palette. |
CReBarCtrl::GetRect | Retrieves the bounding rectangle for a given band in a rebar control. |
CReBarCtrl::GetRowCount | Retrieves the number of band rows in a rebar control. |
CReBarCtrl::GetRowHeight | Retrieves the height of a specified row in a rebar control. |
CReBarCtrl::GetTextColor | Retrieves a rebar control's default text color. |
CReBarCtrl::GetToolTips | Retrieves the handle to any tool tip control associated with the rebar control. |
CReBarCtrl::HitTest | Determines which portion of a rebar band is at a given point on the screen, if a rebar band exists at that point. |
CReBarCtrl::IDToIndex | Converts a band identifier (ID) to a band index in a rebar control. |
CReBarCtrl::InsertBand | Inserts a new band in a rebar control. |
CReBarCtrl::MaximizeBand | Resizes a band in a rebar control to its largest size. |
CReBarCtrl::MinimizeBand | Resizes a band in a rebar control to its smallest size. |
CReBarCtrl::MoveBand | Moves a band from one index to another. |
CReBarCtrl::PushChevron | Programmatically pushes a chevron. |
CReBarCtrl::RestoreBand | Resizes a band in a rebar control to its ideal size. |
CReBarCtrl::SetBandInfo | Sets characteristics of an existing band in a rebar control. |
CReBarCtrl::SetBandWidth | Sets the width of the specified docked band in the current rebar control. |
CReBarCtrl::SetBarInfo | Sets the characteristics of a rebar control. |
CReBarCtrl::SetBkColor | Sets a rebar control's default background color. |
CReBarCtrl::SetColorScheme | Sets the color scheme for the buttons on a rebar control. |
CReBarCtrl::SetExtendedStyle | Sets the extended styles for the current rebar control. |
CReBarCtrl::SetImageList | Sets a rebar control's image list. |
CReBarCtrl::SetOwner | Sets a rebar control's owner window. |
CReBarCtrl::SetPalette | Sets the rebar control's current palette. |
CReBarCtrl::SetTextColor | Sets a rebar control's default text color. |
CReBarCtrl::SetToolTips | Associates a tool tip control with the rebar control. |
CReBarCtrl::SetWindowTheme | Sets the visual style of the rebar control. |
CReBarCtrl::ShowBand | Shows or hides a given band in a rebar control. |
CReBarCtrl::SizeToRect | Fits a rebar control to a specified rectangle. |
The application in which the rebar control resides assigns the child window contained by the rebar control to the rebar band. The child window is usually another common control.
Rebar controls contain one or more bands. Each band can contain a combination of a gripper bar, a bitmap, a text label, and a child window. The band can contain only one of each of these items.
The rebar control can display the child window over a specified background bitmap. All rebar control bands can be resized, except those that use the RBBS_FIXEDSIZE style. As you reposition or resize a rebar control band, the rebar control manages the size and position of the child window assigned to that band. To resize or change the order of bands within the control, click and drag a band's gripper bar.
The following illustration shows a rebar control that has three bands:
-
Band 0 contains a flat, transparent toolbar control.
-
Band 1 contains both transparent standard and transparent dropdown buttons.
-
Band 2 contains a combo box and four standard buttons.
Rebar controls support:
-
Image lists.
-
Message-handling.
-
Custom draw functionality.
-
A variety of control styles in addition to standard window styles. For a list of these styles, see Rebar Control Styles in the Windows SDK.
For more information, see Using CReBarCtrl.
CReBarCtrl
Header: afxcmn.h
Implements the behavior of the Win32 message RB_BEGINDRAG, as described in the Windows SDK.
void BeginDrag(
UINT uBand,
DWORD dwPos = (DWORD)-1);
uBand
Zero-based index of the band that the drag-and-drop operation will affect.
dwPos
A DWORD value that contains the starting mouse coordinates. The horizontal coordinate is contained in the LOWORD and the vertical coordinate is contained in the HIWORD. If you pass (DWORD)-1, the rebar control will use the position of the mouse the last time the control's thread called GetMessage
or PeekMessage
.
Creates the rebar control and attaches it to the CReBarCtrl
object.
virtual BOOL Create(
DWORD dwStyle,
const RECT& rect,
CWnd* pParentWnd,
UINT nID);
dwStyle
Specifies the combination of rebar control styles applied to the control. See Rebar Control Styles in the Windows SDK for a list of supported styles.
rect
A reference to a CRect object or RECT structure, which is the position and size of the rebar control.
pParentWnd
A pointer to a CWnd object that is the parent window of the rebar control. It must not be NULL.
nID
Specifies the rebar control's control ID.
Nonzero if the object was created successfully; otherwise 0.
Create a rebar control in two steps:
-
Call CReBarCtrl to construct a
CReBarCtrl
object. -
Call this member function, which creates the Windows rebar control and attaches it to the
CReBarCtrl
object.
When you call Create
, the common controls are initialized.
[!code-cppNVC_MFC_CReBarCtrl#3]
Creates a control (a child window) and associates it with the CReBarCtrl
object.
virtual BOOL CreateEx(
DWORD dwExStyle,
DWORD dwStyle,
const RECT& rect,
CWnd* pParentWnd,
UINT nID);
dwExStyle
Specifies the extended style of the control being created. For a list of extended Windows styles, see the dwExStyle parameter for CreateWindowEx in the Windows SDK.
dwStyle
Specifies the combination of rebar control styles applied to the control. For a list of supported styles, see Rebar Control Styles in the Windows SDK.
rect
A reference to a RECT structure describing the size and position of the window to be created, in client coordinates of pParentWnd.
pParentWnd
A pointer to the window that is the control's parent.
nID
The control's child-window ID.
Nonzero if successful; otherwise 0.
Use CreateEx
instead of Create to apply extended Windows styles, specified by the Windows extended style preface WS_EX_.
Creates a CReBarCtrl
object.
CReBarCtrl();
See the example for CReBarCtrl::Create.
Implements the behavior of the Win32 message RB_DELETEBAND, as described in the Windows SDK.
BOOL DeleteBand(UINT uBand);
uBand
Zero-based index of the band to be deleted.
Nonzero if the band deleted successfully; otherwise zero.
[!code-cppNVC_MFC_CReBarCtrl#4]
Implements the behavior of the Win32 message RB_DRAGMOVE, as described in the Windows SDK.
void DragMove(DWORD dwPos = (DWORD)-1);
dwPos
A DWORD value that contains the new mouse coordinates. The horizontal coordinate is contained in the LOWORD and the vertical coordinate is contained in the HIWORD. If you pass (DWORD)-1, the rebar control will use the position of the mouse the last time the control's thread called GetMessage
or PeekMessage
.
Implements the behavior of the Win32 message RB_ENDDRAG, as described in the Windows SDK.
void EndDrag();
Implements the behavior of the Win32 message RB_GETBANDBORDERS, as described in the Windows SDK.
void GetBandBorders(
UINT uBand,
LPRECT prc) const;
uBand
Zero-based index of the band for which the borders will be retrieved.
prc
A pointer to a RECT structure that will receive the band borders. If the rebar control has the RBS_BANDBORDERS style, each member of this structure will receive the number of pixels, on the corresponding side of the band, that constitute the border. If the rebar control does not have the RBS_BANDBORDERS style, only the left member of this structure receives valid information. For a description of rebar control styles, see Rebar Control Styles in the Windows SDK.
Implements the behavior of the Win32 message RB_GETBANDCOUNT, as described in the Windows SDK.
UINT GetBandCount() const;
The number of bands assigned to the control.
Implements the behavior of the Win32 message RB_GETBANDINFO as described in the Windows SDK.
BOOL GetBandInfo(
UINT uBand,
REBARBANDINFO* prbbi) const;
uBand
Zero-based index of the band for which the information will be retrieved.
prbbi
A pointer to a REBARBANDINFO structure to receive the band information. You must set the cbSize
member of this structure to sizeof(REBARBANDINFO)
and set the fMask
member to the items you want to retrieve before sending this message.
Nonzero if successful; otherwise zero.
Retrieves the margins of the band.
void GetBandMargins(PMARGINS pMargins);
pMargins
A pointer to a MARGINSstructure that will receive the information.
This member function emulates the functionality of the RB_GETBANDMARGINS message, as described in the Windows SDK.
Retrieves the height of the rebar bar.
UINT GetBarHeight() const;
Value that represents the height, in pixels, of the control.
Implements the behavior of the Win32 message RB_GETBARINFO, as described in the Windows SDK.
BOOL GetBarInfo(REBARINFO* prbi) const;
prbi
A pointer to a REBARINFO structure that will receive the rebar control information. You must set the cbSize member of this structure to sizeof(REBARINFO)
before sending this message.
Nonzero if successful; otherwise zero.
Implements the behavior of the Win32 message RB_GETBKCOLOR, as described in the Windows SDK.
COLORREF GetBkColor() const;
A COLORREF value that represent the current default background color.
Retrieves the COLORSCHEME structure for the rebar control.
BOOL GetColorScheme(COLORSCHEME* lpcs);
lpcs
A pointer to a COLORSCHEME structure, as described in the Windows SDK.
Nonzero if successful; otherwise zero.
The COLORSCHEME
structure includes the button highlight color and the button shadow color.
Implements the behavior of the Win32 message RB_GETDROPTARGET, as described in the Windows SDK.
IDropTarget* GetDropTarget() const;
A pointer to an IDropTarget interface.
Gets the extended styles of the current rebar control.
DWORD GetExtendedStyle() const;
A bitwise combination (OR) of flags that indicate the extended styles. The possible flags are RBS_EX_SPLITTER and RBS_EX_TRANSPARENT. For more information, see the dwMask parameter of the CReBarCtrl::SetExtendedStyle method.
This method sends the RB_GETEXTENDEDSTYLE message, which is described in the Windows SDK.
Gets the CImageList
object associated with a rebar control.
CImageList* GetImageList() const;
A pointer to a CImageList object. Returns NULL if no image list is set for the control.
This member function uses size and mask information stored in the REBARINFO structure, as described in the Windows SDK.
Retrieves the rebar control's current palette.
CPalette* GetPalette() const;
A pointer to a CPalette object specifying the rebar control's current palette.
Note that this member function uses a CPalette
object as its return value, rather than an HPALETTE.
[!code-cppNVC_MFC_CReBarCtrl#5]
Implements the behavior of the Win32 message RB_GETRECT, as described in the Windows SDK.
BOOL GetRect(
UINT uBand,
LPRECT prc) const;
uBand
Zero-based index of a band in the rebar control.
prc
A pointer to a RECT structure that will receive the bounds of the rebar band.
Nonzero if successful; otherwise zero.
[!code-cppNVC_MFC_CReBarCtrl#6]
Implements the behavior of the Win32 message RB_GETROWCOUNT, as described in the Windows SDK.
UINT GetRowCount() const;
A UINT value that represents the number of band rows in the control.
[!code-cppNVC_MFC_CReBarCtrl#7]
Implements the behavior of the Win32 message RB_GETROWHEIGHT, as described in the Windows SDK.
UINT GetRowHeight(UINT uRow) const;
uRow
Zero-based index of the band that will have its height retrieved.
A UINT value that represents the row height, in pixels.
[!code-cppNVC_MFC_CReBarCtrl#8]
Implements the behavior of the Win32 message RB_GETTEXTCOLOR, as described in the Windows SDK.
COLORREF GetTextColor() const;
A COLORREF value that represent the current default text color.
Implements the behavior of the Win32 message RB_GETTOOLTIPS, as described in the Windows SDK.
CToolTipCtrl* GetToolTips() const;
A pointer to a CToolTipCtrl object.
Note that the MFC implementation of GetToolTips
returns a pointer to a CToolTipCtrl
, rather than an HWND.
Implements the behavior of the Win32 message RB_HITTEST, as described in the Windows SDK.
int HitTest(RBHITTESTINFO* prbht);
prbht
A pointer to a RBHITTESTINFO structure. Before sending the message, the pt
member of this structure must be initialized to the point that will be tested, in client coordinates.
The zero-based index of the band at the given point, or -1 if no rebar band was at the point.
Implements the behavior of the Win32 message RB_IDTOINDEX, as described in the Windows SDK.
int IDToIndex(UINT uBandID) const;
uBandID
The application-defined identifier of the specified band, passed in the wID
member of the REBARBANDINFO structure when the band is inserted.
The zero-based band index if successful, or -1 otherwise. If duplicate band indices exist, the first one is returned.
Implements the behavior of the Win32 message RB_INSERTBAND, as described in the Windows SDK.
BOOL InsertBand(
UINT uIndex,
REBARBANDINFO* prbbi);
uIndex
Zero-based index of the location where the band will be inserted. If you set this parameter to -1, the control will add the new band at the last location.
prbbi
A pointer to a REBARBANDINFO structure that defines the band to be inserted. You must set the cbSize member of this structure to sizeof(REBARBANDINFO)
before calling this function.
Nonzero if successful; otherwise zero.
[!code-cppNVC_MFC_CReBarCtrl#9]
Resizes a band in a rebar control to its largest size.
void MaximizeBand(UINT uBand);
uBand
Zero-based index of the band to be maximized.
Implements the behavior of the Win32 message RB_MAXIMIZEBAND with fIdeal
set to 0, as described in the Windows SDK.
[!code-cppNVC_MFC_CReBarCtrl#10]
Resizes a band in a rebar control to its smallest size.
void MinimizeBand(UINT uBand);
uBand
Zero-based index of the band to be minimized.
Implements the behavior of the Win32 message RB_MINIMIZEBAND, as described in the Windows SDK.
[!code-cppNVC_MFC_CReBarCtrl#11]
Implements the behavior of the Win32 message RB_MOVEBAND, as described in the Windows SDK.
BOOL MoveBand(
UINT uFrom,
UINT uTo);
uFrom
Zero-based index of the band to be moved.
uTo
Zero-based index of the new band position. This parameter value must never be greater than the number of bands minus one. To obtain the number of bands, call GetBandCount.
Nonzero if successful; otherwise zero.
Implements the behavior of the Win32 message RB_PUSHCHEVRON, as described in the Windows SDK.
void PushChevron(
UINT uBand,
LPARAM lAppValue);
uBand
Zero-based index of the band whose chevron is to be pushed.
lAppValue
An application defined 32-bit value. See lAppValue in RB_PUSHCHEVRON in the Windows SDK.
Resizes a band in a rebar control to its ideal size.
void RestoreBand(UINT uBand);
uBand
Zero-based index of the band to be maximized.
Implements the behavior of the Win32 message RB_MAXIMIZEBAND with fIdeal
set to 1, as described in the Windows SDK.
[!code-cppNVC_MFC_CReBarCtrl#12]
Implements the behavior of the Win32 message RB_SETBANDINFO, as described in the Windows SDK.
BOOL SetBandInfo(
UINT uBand,
REBARBANDINFO* prbbi);
uBand
Zero-based index of the band to receive the new settings.
prbbi
Pointer to a REBARBANDINFO structure that defines the band to be inserted. You must set the cbSize
member of this structure to sizeof(REBARBANDINFO)
before sending this message.
Nonzero if successful; otherwise zero.
[!code-cppNVC_MFC_CReBarCtrl#13]
Sets the width of the specified docked band in the current rebar control.
BOOL SetBandWidth(
UINT uBand,
int cxWidth);
uBand
[in] Zero-based index of a rebar band.
cxWidth
[in] New width of the rebar band, in pixels.
TRUE if the method is successful; otherwise, FALSE.
This method sends the RB_SETBANDWIDTH message, which is described in the Windows SDK.
The first code example defines the variable, m_rebar
, that is used to access the current rebar control. This variable is used in the next example.
[!code-cppNVC_MFC_CReBarCtrl_s1#1]
The next code example sets each rebar band to be the same width.
[!code-cppNVC_MFC_CReBarCtrl_s1#2]
Implements the behavior of the Win32 message RB_SETBARINFO, as described in the Windows SDK.
BOOL SetBarInfo(REBARINFO* prbi);
prbi
A pointer to a REBARINFO structure that contains the information to be set. You must set the cbSize
member of this structure to sizeof(REBARINFO)
before sending this message
Nonzero if successful; otherwise zero.
[!code-cppNVC_MFC_CReBarCtrl#14]
Implements the behavior of the Win32 message RB_SETBKCOLOR, as described in the Windows SDK.
COLORREF SetBkColor(COLORREF clr);
clr
The COLORREF value that represents the new default background color.
A COLORREF value that represents the previous default background color.
See this topic for more information about when to set the background color, and how to set the default.
Sets the color scheme for the buttons on a rebar control.
void SetColorScheme(const COLORSCHEME* lpcs);
lpcs
A pointer to a COLORSCHEME structure, as described in the Windows SDK.
The COLORSCHEME
structure includes both the button highlight color and the button shadow color.
Sets the extended styles for the current rebar control.
DWORD SetExtendedStyle(
DWORD dwMask,
DWORD dwStyleEx);
dwMask
[in] A bitwise combination (OR) of flags that specify which flags in the dwStyleEx parameter apply. Use one or more of the following values:
RBS_EX_SPLITTER
: By default, show the splitter on the bottom in horizontal mode, and to the right in vertical mode.RBS_EX_TRANSPARENT
: Forward the WM_ERASEBKGND message to the parent window.
dwStyleEx
[in] A bitwise combination (OR) of flags that specify the styles to apply. To set a style, specify the same flag that is used in the dwMask parameter. To reset a style, specify binary zero.
The previous extended style.
This method sends the RB_SETEXTENDEDSTYLE message, which is described in the Windows SDK.
Assigns an image list to a rebar control.
BOOL SetImageList(CImageList* pImageList);
pImageList
A pointer to a CImageList object containing the image list to be assigned to the rebar control.
Nonzero if successful; otherwise zero.
Implements the behavior of the Win32 message RB_SETPARENT, as described in the Windows SDK.
CWnd* SetOwner(CWnd* pWnd);
pWnd
A pointer to a CWnd
object to set as the owner of the rebar control.
A pointer to a CWnd object that is the current owner of the rebar control.
Note that this member function uses pointers to CWnd
objects for both the current and selected owner of the rebar control, rather than handles to windows.
Note
This member function does not change the actual parent that was set when the control was created; rather it sends notification messages to the window you specify.
Implements the behavior of the Win32 message RB_SETPALETTE, as described in the Windows SDK.
CPalette* SetPalette(HPALETTE hPal);
hPal
An HPALETTE that specifies the new palette that the rebar control will use.
A pointer to a CPalette object specifying the rebar control's previous palette.
Note that this member function uses a CPalette
object as its return value, rather than an HPALETTE.
Implements the behavior of the Win32 message RB_SETTEXTCOLOR, as described in the Windows SDK.
COLORREF SetTextColor(COLORREF clr);
clr
A COLORREF value that represents the new text color in the CReBarCtrl
object.
The COLORREF value representing the previous text color associated with the CReBarCtrl
object.
It is provided to support text color flexibility in a rebar control.
Associates a tool tip control with a rebar control.
void SetToolTips(CToolTipCtrl* pToolTip);
pToolTip
A pointer to a CToolTipCtrl object
You must destroy the CToolTipCtrl
object when you are done with it.
Sets the visual style of the rebar control.
HRESULT SetWindowTheme(LPCWSTR pszSubAppName);
pszSubAppName
A pointer to a Unicode string that contains the rebar visual style to set.
The return value is not used.
This member function emulates the functionality of the RB_SETWINDOWTHEME message, as described in the Windows SDK.
Implements the behavior of the Win32 message RB_SHOWBAND, as described in the Windows SDK.
BOOL ShowBand(
UINT uBand,
BOOL fShow = TRUE);
uBand
Zero-based index of a band in the rebar control.
fShow
Indicates if the band should be shown or hidden. If this value is TRUE, the band will be shown. Otherwise, the band will be hidden.
Nonzero if successful; otherwise zero.
Implements the behavior of the Win32 message RB_SIZETORECT, as described in the Windows SDK.
BOOL SizeToRect(CRect& rect);
rect
A reference to a CRect object that specifies the rectangle that the rebar control should be sized to.
Nonzero if successful; otherwise zero.
Note that this member function uses a CRect
object as a parameter, rather than a RECT
structure.