Help Center
Help CenterAfxNovaWindows

CToolbar Class

Members (102)

AddBitmapAdds one or more images to the list of button images available for a toolbar.AddButtonAdds a button to a toolbar.AddButtonsAdds one or more buttons to a toolbar.AddSeparatorAdds a separator to a toolbar.AddStringAdds a new string to the toolbar's string pool.AutoSizeCauses a toolbar to be resized.ButtonCountRetrieves a count of the buttons currently in the toolbar.ButtonStructSizeRetrieves a count of the buttons currently in the toolbar.ChangeBitmapRetrieves a count of the buttons currently in the toolbar.CheckButtonChecks a given button in a toolbar.CommandToIndexRetrieves the zero-based index for the button associated with the specified command identifier.CustomizeDisplays the Customize Toolbar dialog box.DeleteButtonDeletes a button from the toolbar.DisableButtonDisables the specified button in a toolbar.EnableButtonEnables the specified button in a toolbar.GetAnchorHighlightRetrieves the anchor highlight setting for a toolbar.GetBitmapRetrieves the index of the bitmap associated with a button in a toolbar.GetBitmapFlagsRetrieves the flags that describe the type of bitmap to be used.GetButtonRetrieves information about the specified button in a toolbar.GetButtonHeightRetrieves the current height of toolbar buttons, in pixels.GetButtonInfoRetrieves extended information for a button in a toolbar.GetButtonSizeRetrieves the current width and height of toolbar buttons, in pixels.GetButtonTextRetrieves the display text of a button on a toolbar.GetButtonTextLengthRetrieves the length of the display text of a button on a toolbar.GetButtonWidthRetrieves the current width of toolbar buttons, in pixels.GetColorSchemeRetrieves the color scheme information from the toolbar control.GetDisabledImageListRetrieves the image list that a toolbar control uses to display inactive buttons.GetExtendedStyleRetrieves the extended styles for a toolbar control.GetHorizontalPaddingRetrieves the horizontal padding for a toolbar control.GetHotImageListRetrieves the image list that a toolbar control uses to display hot buttons.GetHotItemRetrieves the index of the hot item in a toolbar.GetImageListRetrieves the image list that a toolbar control uses to display buttons in their default state.GetImageListCountReturns the number of image lists.GetInsertMarkRetrieves the current insertion mark for the toolbar.GetInsertMarkColorRetrieves the color used to draw the insertion mark for the toolbar.GetItemRectRetrieves the bounding rectangle of a button in a toolbar.GetMaxSizeRetrieves the total size of all of the visible buttons and separators in the toolbar.GetMetricsRetrieves the metrics of a toolbar control.GetObjectRetrieves the IDropTarget for a toolbar control.GetPaddingRetrieves the padding for a toolbar control.GetRectRetrieves the bounding rectangle for a specified toolbar button.GetRowsRetrieves the number of rows of buttons in a toolbar with the TBSTYLE_WRAPABLE style.GetStateRetrieves information about the state of the specified button in a toolbar, such as whether it is enabled, pressed, or checked.GetStringRetrieves a string from a toolbar's string pool.GetStyleRetrieves the styles currently in use for a toolbar control.GetTextRowsRetrieves the number of rows of buttons in a toolbar with the TBSTYLE_WRAPABLE style.GetTooltipsRetrieves the handle to the tooltip control, if any, associated with the toolbar.GetVerticalPaddingRetrieves the vertical padding for a toolbar control.HideButtonHides or shows the specified button in a toolbar.HighlightButtonSets the highlight state of a given button in a toolbar control.HitTestDetermines where a point lies in a toolbar control.IndeterminateSets or clears the indeterminate state of the specified button in a toolbar.InsertButtonInserts a button in a toolbar.InsertMarkHitTestRetrieves the insertion mark information for a point in a toolbar.InsertSeparatorInserts a separator in a toolbar.IsButtonCheckedDetermines whether the specified button in a toolbar is checked.IsButtonEnabledDetermines whether the specified button in a toolbar is enabled.IsButtonHiddenDetermines whether the specified button in a toolbar is hidden.IsButtonHighlightedChecks the highlight state of a toolbar button.IsButtonIndeterminateDetermines whether the specified button in a toolbar is indeterminate.IsButtonPressedDetermines whether the specified button in a toolbar is pressed.LoadImagesLoads system-defined button images into a toolbar control's image list.MakeOpaqueMakes the toolbar opaque by removing the TBSTYLE_TRANSPARENT style.MapAcceleratorDetermines the ID of the button that corresponds to the specified accelerator character.MarkButtonSets the highlight state of a given button in a toolbar control.MoveButtonMoves a button from one index to another.PressButtonPresses the specified button in a toolbar.ReleaseButtonReleases the specified button in a toolbar.RemoveDarkModeRemoves the toolbar dark mode.ReplaceBitmapReplaces an existing bitmap with a new bitmap.SaveRestoreSend this message to initiate saving or restoring a toolbar state.SetAnchorHighlightSets the anchor highlight setting for a toolbar.SetBitmapSizeSets the size of the bitmapped images to be added to a toolbar.SetButtonInfoSets the information for an existing button in a toolbar.SetButtonSizeSets the size of buttons on a toolbar.SetButtonWidthSets the minimum and maximum button widths in the toolbar control.SetCmdIdSets the command identifier of a toolbar button.SetColorSchemeSets the color scheme information for the toolbar control.SetDarkModeSets the toolbar dark mode.SetDisabledImageListSets the image list that the toolbar control will use to display disabled buttons.SetDrawTextFlagsSets the text drawing flags for the toolbar.SetExtendedStyleSets the extended styles for a toolbar control.SetHotImageListSets the image list that the toolbar control will use to display hot buttons.SetHotItemSets the hot item in a toolbar.SetImageListSets the image list that the toolbar will use to display buttons that are in their default state.SetIndentSets the indentation for the first button in a toolbar control.SetInsertMarkSets the current insertion mark for the toolbar.SetInsertMarkColorSets the color used to draw the insertion mark for the toolbar.SetListGapSets the distance between the toolbar buttons on a specific toolbar.SetMaxTextRowsSets the maximum number of text rows displayed on a toolbar button.SetMetricsSets the metrics of a toolbar control.SetPaddingSets the padding for a toolbar control.SetParentSets the window to which the toolbar control sends notification messages.SetPressedImageListSets the image list that the toolbar uses to display buttons that are in a pressed state.SetRowsSets the number of rows of buttons in a toolbar.SetStateSets the state for the specified button in a toolbar.SetStyleSets the style for a toolbar control.SetToolTipsAssociates a tooltip control with a toolbar.SetWindowThemeSets the visual style of a toolbar control.UncheckButtonUnchecks a given button in a toolbar.UnhideButtonUnhides the specified button in a toolbar.UnhighlightButtonRemoves the highlight state of a given button in a toolbar control.

Documentation

CToolbar Class

A toolbar is a control that contains one or more buttons. Each button, when clicked by a user, sends a command message to the parent window. Typically, the buttons in a toolbar correspond to items in the application's menu, providing an additional and more direct way for the user to access an application's commands.

See: About Toolbar Controls

Include file: CToolbar.inc

NameDescription
AddBitmapAdds one or more images to the list of button images available for a toolbar.
AddButtonAdds a button to a toolbar.
AddButtonsAdds one or more buttons to a toolbar.
AddSeparatorAdds a separator to a toolbar.
AddStringAdds a new string to the toolbar's string pool.
AutoSizeCauses a toolbar to be resized.
ButtonCountRetrieves a count of the buttons currently in the toolbar.
ButtonStructSizeRetrieves a count of the buttons currently in the toolbar.
ChangeBitmapRetrieves a count of the buttons currently in the toolbar.
CheckButtonChecks a given button in a toolbar.
CommandToIndexRetrieves the zero-based index for the button associated with the specified command identifier.
CustomizeDisplays the Customize Toolbar dialog box.
DeleteButtonDeletes a button from the toolbar.
DisableButtonDisables the specified button in a toolbar.
EnableButtonEnables the specified button in a toolbar.
GetAnchorHighlightRetrieves the anchor highlight setting for a toolbar.
GetBitmapRetrieves the index of the bitmap associated with a button in a toolbar.
GetBitmapFlagsRetrieves the flags that describe the type of bitmap to be used.
GetButtonRetrieves information about the specified button in a toolbar.
GetButtonHeightRetrieves the current height of toolbar buttons, in pixels.
GetButtonInfoRetrieves extended information for a button in a toolbar.
GetButtonSizeRetrieves the current width and height of toolbar buttons, in pixels.
GetButtonTextRetrieves the display text of a button on a toolbar.
GetButtonTextLengthRetrieves the length of the display text of a button on a toolbar.
GetButtonWidthRetrieves the current width of toolbar buttons, in pixels.
GetColorSchemeRetrieves the color scheme information from the toolbar control.
GetDisabledImageListRetrieves the image list that a toolbar control uses to display inactive buttons.
GetExtendedStyleRetrieves the extended styles for a toolbar control.
GetHorizontalPaddingRetrieves the horizontal padding for a toolbar control.
GetHotImageListRetrieves the image list that a toolbar control uses to display hot buttons.
GetHotItemRetrieves the index of the hot item in a toolbar.
GetImageListRetrieves the image list that a toolbar control uses to display buttons in their default state.
GetImageListCountReturns the number of image lists.
GetInsertMarkRetrieves the current insertion mark for the toolbar.
GetInsertMarkColorRetrieves the color used to draw the insertion mark for the toolbar.
GetItemRectRetrieves the bounding rectangle of a button in a toolbar.
GetMaxSizeRetrieves the total size of all of the visible buttons and separators in the toolbar.
GetMetricsRetrieves the metrics of a toolbar control.
GetObjectRetrieves the IDropTarget for a toolbar control.
GetPaddingRetrieves the padding for a toolbar control.
GetRectRetrieves the bounding rectangle for a specified toolbar button.
GetRowsRetrieves the number of rows of buttons in a toolbar with the TBSTYLE_WRAPABLE style.
GetStateRetrieves information about the state of the specified button in a toolbar, such as whether it is enabled, pressed, or checked.
GetStringRetrieves a string from a toolbar's string pool.
GetStyleRetrieves the styles currently in use for a toolbar control.
GetTextRowsRetrieves the number of rows of buttons in a toolbar with the TBSTYLE_WRAPABLE style.
GetTooltipsRetrieves the handle to the tooltip control, if any, associated with the toolbar.
GetVerticalPaddingRetrieves the vertical padding for a toolbar control.
HideButtonHides or shows the specified button in a toolbar.
HighlightButtonSets the highlight state of a given button in a toolbar control.
HitTestDetermines where a point lies in a toolbar control.
IndeterminateSets or clears the indeterminate state of the specified button in a toolbar.
InsertButtonInserts a button in a toolbar.
InsertMarkHitTestRetrieves the insertion mark information for a point in a toolbar.
InsertSeparatorInserts a separator in a toolbar.
IsButtonCheckedDetermines whether the specified button in a toolbar is checked.
IsButtonEnabledDetermines whether the specified button in a toolbar is enabled.
IsButtonHiddenDetermines whether the specified button in a toolbar is hidden.
IsButtonHighlightedChecks the highlight state of a toolbar button.
IsButtonIndeterminateDetermines whether the specified button in a toolbar is indeterminate.
IsButtonPressedDetermines whether the specified button in a toolbar is pressed.
LoadImagesLoads system-defined button images into a toolbar control's image list.
MakeOpaqueMakes the toolbar opaque by removing the TBSTYLE_TRANSPARENT style.
MapAcceleratorDetermines the ID of the button that corresponds to the specified accelerator character.
MarkButtonSets the highlight state of a given button in a toolbar control.
MoveButtonMoves a button from one index to another.
PressButtonPresses the specified button in a toolbar.
ReleaseButtonReleases the specified button in a toolbar.
RemoveDarkModeRemoves the toolbar dark mode.
ReplaceBitmapReplaces an existing bitmap with a new bitmap.
SaveRestoreSend this message to initiate saving or restoring a toolbar state.
SetAnchorHighlightSets the anchor highlight setting for a toolbar.
SetBitmapSizeSets the size of the bitmapped images to be added to a toolbar.
SetButtonInfoSets the information for an existing button in a toolbar.
SetButtonSizeSets the size of buttons on a toolbar.
SetButtonWidthSets the minimum and maximum button widths in the toolbar control.
SetCmdIdSets the command identifier of a toolbar button.
SetColorSchemeSets the color scheme information for the toolbar control.
SetDarkModeSets the toolbar dark mode.
SetDisabledImageListSets the image list that the toolbar control will use to display disabled buttons.
SetDrawTextFlagsSets the text drawing flags for the toolbar.
SetExtendedStyleSets the extended styles for a toolbar control.
SetHotImageListSets the image list that the toolbar control will use to display hot buttons.
SetHotItemSets the hot item in a toolbar.
SetImageListSets the image list that the toolbar will use to display buttons that are in their default state.
SetIndentSets the indentation for the first button in a toolbar control.
SetInsertMarkSets the current insertion mark for the toolbar.
SetInsertMarkColorSets the color used to draw the insertion mark for the toolbar.
SetListGapSets the distance between the toolbar buttons on a specific toolbar.
SetMaxTextRowsSets the maximum number of text rows displayed on a toolbar button.
SetMetricsSets the metrics of a toolbar control.
SetPaddingSets the padding for a toolbar control.
SetParentSets the window to which the toolbar control sends notification messages.
SetPressedImageListSets the image list that the toolbar uses to display buttons that are in a pressed state.
SetRowsSets the number of rows of buttons in a toolbar.
SetStateSets the state for the specified button in a toolbar.
SetStyleSets the style for a toolbar control.
SetToolTipsAssociates a tooltip control with a toolbar.
SetWindowThemeSets the visual style of a toolbar control.
UncheckButtonUnchecks a given button in a toolbar.
UnhideButtonUnhides the specified button in a toolbar.
UnhighlightButtonRemoves the highlight state of a given button in a toolbar control.

AddBitmap

Adds one or more images to the list of button images available for a toolbar.

FUNCTION AddBitmap (BYVAL hToolbar AS HWND, BYVAL nButtons AS DWORD, BYVAL ptabm AS TBADDBITMAP PTR) AS LONG
FUNCTION AddBitmap (BYVAL hToolbar AS HWND, BYVAL nButtons AS DWORD, BYREF tabm AS TBADDBITMAP) AS LONG
ParameterDescription
hToolbarHandle to the toolbar control.
nButtonsNumber of button images in the bitmap. If ptabm specifies a system-defined bitmap, this parameter is ignored.
ptabmPointer to a TBADDBITMAP structure that contains the identifier of a bitmap resource and the handle to the module instance with the executable file that contains the bitmap resource.
tabmA TBADDBITMAP structure that contains the identifier of a bitmap resource and the handle to the module instance with the executable file that contains the bitmap resource.
Return value

Returns the index of the first new image if successful, or -1 otherwise.

Remarks

If the toolbar was created using the CreateWindowExW function, you must send the TB_BUTTONSTRUCTSIZE message to the toolbar before sending TB_ADDBITMAP.


AddButton

Adds one button to a toolbar.

FUNCTION AddButton (BYVAL hToolbar AS HWND, BYVAL idxBitmap AS LONG, BYVAL idCommand AS LONG, _
   BYVAL fsState AS UBYTE = 0, BYVAL fsStyle AS UBYTE = 0, BYVAL dwData AS DWORD_PTR = 0, _
   BYVAL pwszText AS WSTRING PTR = NULL) AS BOOLEAN
ParameterDescription
hToolbarHandle to the toolbar control.
idxBitmapZero-based index of the button image.
idCommandCommand identifier associated with the button. This identifier is used in a WM_COMMAND message when the button is chosen.
fsStateButton state flags. This member can be a combination of the values listed in Toolbar Button States.
fsStyleButton style. This member can be a combination of the button style values listed in Toolbar Control and Button Styles.
dwDataApplication-defined value.
pwszTextPointer to a Unicode string that contains text for the button.
Return value

Returns TRUE if successful, or FALSE otherwise.

Remarks

If the toolbar was created using the CreateWindowExW function, you must send the TB_BUTTONSTRUCTSIZE message to the toolbar before sending TB_ADDBUTTONSW.


AddButtons

Adds one or more buttons to a toolbar.

FUNCTION AddButtons (BYVAL hToolbar AS HWND, BYVAL nButtons AS DWORD, BYVAL lpButtons AS TBBUTTON PTR) AS BOOLEAN
ParameterDescription
hToolbarHandle to the toolbar control.
nButtonsNumber of buttons to add.
lpButtonsPointer to an array of TBBUTTON structures that contain information about the buttons to add. There must be the same number of elements in the array as buttons specified by nButtons.
Return value

Returns TRUE if successful, or FALSE otherwise.

Remarks

If the toolbar was created using the CreateWindowExW function, you must send the TB_BUTTONSTRUCTSIZE message to the toolbar before sending TB_ADDBUTTONSW.

See TB_SETIMAGELIST for a discussion of how to assign bitmaps to toolbar buttons from one or more image lists.


AddSeparator

Adds a separator to a toolbar.

FUNCTION AddSeparator (BYVAL hToolbar AS HWND, BYVAL nWidth AS LONG = 0) AS BOOLEAN
ParameterDescription
hToolbarHandle to the toolbar control.
nWidthWidth of the separator, in pixels
Return value

Returns TRUE if successful, or FALSE otherwise.


AddString

Adds a new string to the toolbar's string pool.

FUNCTION AddString (BYVAL hToolbar AS HWND, BYVAL hInst AS HINSTANCE, BYVAL idString AS INT_PTR) AS LONG
ParameterDescription
hToolbarHandle to the toolbar control.
hInstHandle to the module instance with an executable file that contains the string resource. If idString instead points to a character array with one or more strings, set this parameter to NULL.
idStringResource identifier for the string resource, or a pointer to an array of characters. See Remarks.
Return value

Returns the index of the first new string if successful, or -1 otherwise.

Remarks

If hInst is NULL, idString points to a character array with one or more null-terminated strings. The last string in the array must be terminated with two null characters.

If hInst is the HINSTANCE of the application or of another module containing a string resource, idString is the resource identifier of the string. Each item in the string must begin with an arbitrary separator character, and the string must end with two such characters. For example, the text for three buttons might appear in the string table as "/New/Open/Save//". The message returns the index of "New" in the toolbar's string pool, and the other items are in consecutive positions.


AutoSize

Causes a toolbar to be resized.

SUB AutoSize (BYVAL hToolbar AS HWND)
ParameterDescription
hToolbarHandle to the toolbar control.
Remarks

An application sends the TB_AUTOSIZE message after causing the size of a toolbar to change either by setting the button or bitmap size or by adding strings for the first time.


ButtonCount

Retrieves a count of the buttons currently in the toolbar.

FUNCTION ButtonCount (BYVAL hToolbar AS HWND) AS DWORD
ParameterDescription
hToolbarHandle to the toolbar control.
Return value

Returns the count of the buttons.


ButtonStructSize

Specifies the size of the TBBUTTON structure.

SUB ButtonStructSize (BYVAL hToolbar AS HWND, BYVAL cb AS LONG)
ParameterDescription
hToolbarHandle to the toolbar control.
cbSize, in bytes, of the TBBUTTON structure.
Remarks

The system uses the size to determine which version of the common control dynamic-link library (DLL) is being used.

If an application uses the CreateWindowExW function to create the toolbar, the application must send this message to the toolbar before sending the TB_ADDBITMAP or TB_ADDBUTTONS message.


ChangeBitmap

Changes the bitmap for a button in a toolbar.

FUNCTION ChangeBitmap (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG, BYVAL iBitmap AS WORD) AS BOOLEAN
ParameterDescription
hToolbarHandle to the toolbar control.
idButtonCommand identifier of the button that is to receive a new bitmap.
iBitmapZero-based index of an image in the toolbar's image list. The system displays the specified image in the button. Set this parameter to I_IMAGECALLBACK, and the toolbar will send the TBN_GETDISPINFO notification to retrieve the image index when it is needed.
Return value

Returns TRUE if successful, or FALSE otherwise.


CheckButton

Checks or unchecks a given button in a toolbar.

FUNCTION CheckButton (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG, BYVAL fCheck AS SHORT) AS BOOLEAN
FUNCTION CheckButton (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG) AS BOOLEAN
FUNCTION UncheckButton (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG) AS BOOLEAN
ParameterDescription
hToolbarHandle to the toolbar control.
idButtonCommand identifier of the button to check.
fCheckIf TRUE, the check is added. If FALSE, the check is removed.
Return value

Returns TRUE if successful, or FALSE otherwise.

Remarks

When a button is checked, it is displayed in the pressed state.


CommandToIndex

Retrieves the zero-based index for the button associated with the specified command identifier.

FUNCTION CommandToIndex (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG) AS LONG
ParameterDescription
hToolbarHandle to the toolbar control.
idButtonCommand identifier associated with the button.
Return value

Returns the zero-based index for the button or -1 if the specified command identifier is invalid.


Customize

Displays the Customize Toolbar dialog box.

SUB Customize (BYVAL hToolbar AS HWND)
ParameterDescription
hToolbarHandle to the toolbar control.
Note

The toolbar must handle the TBN_QUERYINSERT and TBN_QUERYDELETE notifications for the Customize Toolbar dialog box to appear. If the toolbar does not handle those notifications, TB_CUSTOMIZE has no effect.


DeleteButton

Deletes a button from the toolbar.

FUNCTION DeleteButton (BYVAL hToolbar AS HWND, BYVAL nButton AS LONG) AS BOOLEAN
ParameterDescription
hToolbarHandle to the toolbar control.
nButtonZero-based index of the button to delete.
Return value

Returns TRUE if successful, or FALSE otherwise.


DisableButton

Disables the specified button in a toolbar.

FUNCTION DisableButton (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG) AS BOOLEAN
ParameterDescription
hToolbarHandle to the toolbar control.
idButtonCommand identifier of the button to disable.
Return value

Returns TRUE if successful, or FALSE otherwise.


EnableButton

Enables the specified button in a toolbar.

FUNCTION EnableButton (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG) AS BOOLEAN
ParameterDescription
hToolbarHandle to the toolbar control.
idButtonCommand identifier of the button to enable.
Return value

Returns TRUE if successful, or FALSE otherwise.

Remarks

When a button has been enabled, it can be pressed and checked.


GetAnchorHighlight

Retrieves the anchor highlight setting for a toolbar.

FUNCTION GetAnchorHighlight (BYVAL hToolbar AS HWND) AS BOOLEAN
ParameterDescription
hToolbarHandle to the toolbar control.
Return value

Returns a Boolean value that indicates if anchor highlighting is set. If this value is nonzero, anchor highlighting is enabled. If this value is zero, it is disabled.


GetBitmap

Retrieves the index of the bitmap associated with a button in a toolbar.

FUNCTION GetBitmap (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG) AS LONG
ParameterDescription
hToolbarHandle to the toolbar control.
idButtonCommand identifier of the button whose bitmap index is to be retrieved.
Return value

Returns the index of the bitmap if successful, or zero otherwise.


GetBitmapFlags

Retrieves the flags that describe the type of bitmap to be used.

FUNCTION GetBitmapFlags (BYVAL hToolbar AS HWND) AS DWORD
ParameterDescription
hToolbarHandle to the toolbar control.
Return value

Returns a DWORD value that describes the type of bitmap that should be used. If this return value has the TBBF_LARGE flag set, applications should use large bitmaps (24 x 24); otherwise, applications should use small bitmaps (16 x 16). All other bits are reserved.

Remarks

The value returned by TB_GETBITMAPFLAGS is only advisory. The toolbar control recommends large or small bitmaps based upon whether the user has chosen large or small fonts.


GetButton

Retrieves information about the specified button in a toolbar.

FUNCTION GetButton (BYVAL hToolbar AS HWND, BYVAL nButton AS LONG, BYVAL ptbb AS TBBUTTON PTR) AS BOOLEAN
FUNCTION GetButton (BYVAL hToolbar AS HWND, BYVAL nButton AS LONG, BYREF tbb AS TBBUTTON) AS BOOLEAN
FUNCTION GetButton (BYVAL hToolbar AS HWND, BYVAL nButton AS LONG) AS TBBUTTON
ParameterDescription
hToolbarHandle to the toolbar control.
nButtonZero-based index of the button for which to retrieve information.
ptbbPointer to the TBBUTTON structure that receives the button information.
tbbA TBBUTTON structure that receives the button information.
Return value

Returns TRUE if successful, or FALSE otherwise.


GetButtonHeight

Retrieves the current height of toolbar buttons, in pixels.

FUNCTION GetButtonHeight (BYVAL hToolbar AS HWND) AS DWORD
ParameterDescription
hToolbarHandle to the toolbar control.

GetButtonInfo

Retrieves extended information for a button in a toolbar.

FUNCTION GetButtonInfo (BYVAL hToolbar AS HWND, BYVAL iID AS LONG, BYVAL ptbbi AS TBBUTTONINFOW PTR) AS LONG
FUNCTION GetButtonInfo (BYVAL hToolbar AS HWND, BYVAL iID AS LONG, BYREF tbbi AS TBBUTTONINFOW) AS LONG
FUNCTION GetButtonInfo (BYVAL hToolbar AS HWND, BYVAL iID AS LONG) AS TBBUTTONINFOW
ParameterDescription
hToolbarHandle to the toolbar control.
iIDCommand identifier of the button.
ptbbiPointer to a TBBUTTONINFOW structure that receives the button information. The cbSize and dwMask members of this structure must be filled in prior to sending this message.
tbbiA TBBUTTONINFOW structure that receives the button information. The cbSize and dwMask members of this structure must be filled in prior to sending this message.
Return value

Returns the zero-based index of the button, or -1 if an error occurs.

Remarks

When you use TB_ADDBUTTONSW or TB_INSERTBUTTONW to place buttons on the toolbar, the button text is commonly specified by its string pool index. TB_GETBUTTONINFOW will not retrieve this string. To use TB_GETBUTTONINFOW to retrieve button text, you must first set the text string with TB_SETBUTTONINFOW. Once you have set the button text with TB_SETBUTTONINFOW, you can no longer use the string pool index.


GetButtonSize

Retrieves the current width and height of toolbar buttons, in pixels.

FUNCTION GetButtonSize (BYVAL hToolbar AS HWND) AS DWORD
ParameterDescription
hToolbarHandle to the toolbar control.
Return value

Returns a DWORD value that contains the width and height values in the low word and high word, respectively.


GetButtonWidth

Retrieves the current width of toolbar buttons, in pixels.

FUNCTION GetButtonWidth (BYVAL hToolbar AS HWND) AS DWORD
ParameterDescription
hToolbarHandle to the toolbar control.

GetButtonText

Retrieves the display text of a button on a toolbar.

FUNCTION GetButtonText (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG, BYVAL pBuffer AS WSTRING PTR) AS LONG
FUNCTION GetButtonText (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG) AS DWSTRING
ParameterDescription
hToolbarHandle to the toolbar control.
idButtonCommand identifier of the button whose text is to be retrieved.
pBufferPointer to a buffer that receives the button text.
Return value

Returns the length, in characters, of the string pointed to by idButton. The length does not include the terminating null character. If unsuccessful, the return value is -1.

Remarks

Security Warning: Using the first overloades function incorrectly might compromise the security of your program. This function does not provide a way for you to know the size of the buffer. If you use this function, first call the function passing NULL in the pBuffer, this returns the number of characters, excluding NULL that are required. Then call the function a second time to retrieve the string.

The returned string corresponds to the text that is currently displayed by the button.


GetButtonTextLength

Retrieves the length of the display text of a button on a toolbar.

FUNCTION GetButtonTextLength (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG) AS LONG
ParameterDescription
hToolbarHandle to the toolbar control.
idButtonCommand identifier of the button whose text length is to be retrieved.

GetColorScheme

Retrieves the color scheme information from the toolbar control.

FUNCTION GetColorScheme (BYVAL hToolbar AS HWND, BYVAL pcs AS COLORSCHEME PTR) AS BOOLEAN
FUNCTION GetColorScheme (BYVAL hToolbar AS HWND, BYREF cs AS COLORSCHEME) AS BOOLEAN
FUNCTION GetColorScheme (BYVAL hToolbar AS HWND) AS COLORSCHEME
ParameterDescription
hToolbarHandle to the toolbar control.
pcsPointer to a COLORSCHEME structure that will receive the color scheme information.
pcsA COLORSCHEME structure that will receive the color scheme information.
Return value

Returns nonzero if successful, or zero otherwise.


GetDisabledImageList

Retrieves the image list that a toolbar control uses to display inactive buttons.

FUNCTION GetDisabledImageList (BYVAL hToolbar AS HWND) AS HIMAGELIST
ParameterDescription
hToolbarHandle to the toolbar control.
Return value

Returns the handle to the inactive image list, or NULL if no inactive image list is set.


GetExtendedStyle

Retrieves the extended styles for a toolbar control.

FUNCTION GetExtendedStyle (BYVAL hToolbar AS HWND) AS DWORD
ParameterDescription
hToolbarHandle to the toolbar control.
Return value

Returns a DWORD that represents the styles currently in use for the toolbar control. This value can be a combination of extended styles.


GetPadding

Retrieves the padding for a toolbar control.

FUNCTION GetPadding (BYVAL hToolbar AS HWND) AS DWORD
ParameterDescription
hToolbarHandle to the toolbar control.
Return value

Returns a DWORD value that contains the horizontal padding in the low word and the vertical padding in the high word, in pixels.


GetHorizontalPadding

Retrieves the horizontal padding for a toolbar control.

FUNCTION GetHorizontalPadding (BYVAL hToolbar AS HWND) AS DWORD
ParameterDescription
hToolbarHandle to the toolbar control.

GetVerticalPadding

Retrieves the vertical padding for a toolbar control.

FUNCTION GetVerticalPadding (BYVAL hToolbar AS HWND) AS DWORD
ParameterDescription
hToolbarHandle to the toolbar control.

GetHotImageList

Retrieves the image list that a toolbar control uses to display hot buttons.

FUNCTION GetHotImageList (BYVAL hToolbar AS HWND) AS HIMAGELIST
ParameterDescription
hToolbarHandle to the toolbar control.
Return value

Returns the handle to the image list that the control uses to display hot buttons, or NULL if no hot image list is set.

Remarks

A button is hot when the cursor is over it. Toolbar controls must have the TBSTYLE_FLAT or TBSTYLE_LIST style to have hot items.


GetHotItem

Retrieves the index of the hot item in a toolbar.

FUNCTION GetHotItem (BYVAL hToolbar AS HWND) AS DWORD
ParameterDescription
hToolbarHandle to the toolbar control.
Return value

Returns the index of the hot item, or -1 if no hot item is set. Toolbar controls that do not have the TBSTYLE_FLAT style do not have hot items.


GetImageList

Retrieves the image list that a toolbar control uses to display buttons in their default state. A toolbar control uses this image list to display buttons when they are not hot or disabled.

FUNCTION GetImageList (BYVAL hToolbar AS HWND) AS HIMAGELIST
ParameterDescription
hToolbarHandle to the toolbar control.
Return value

Returns the handle to the image list, or NULL if no image list is set.


GetImageListCount

Gets the number of image lists associated with the toolbar.

FUNCTION GetImageListCount (BYVAL hToolbar AS HWND) AS LONG
ParameterDescription
hToolbarHandle to the toolbar control.
Return value

Returns the number of image lists.


GetInsertMark

Retrieves the current insertion mark for the toolbar.

FUNCTION GetInsertMark (BYVAL hToolbar AS HWND) AS TBINSERTMARK
ParameterDescription
hToolbarHandle to the toolbar control.
Return value

Returns a TBINSERTMARK structure that receives the insertion mark.


GetInsertMarkColor

Retrieves the current insertion mark for the toolbar.

FUNCTION GetInsertMarkColor (BYVAL hToolbar AS HWND) AS COLORREF
ParameterDescription
hToolbarHandle to the toolbar control.
Return value

Returns a COLORREF value that contains the current insertion mark color.


GetItemRect

Retrieves the bounding rectangle of a button in a toolbar.

FUNCTION GetItemRect (BYVAL hToolbar AS HWND, BYVAL nButton AS LONG, BYVAL prc AS RECT PTR) AS BOOLEAN
FUNCTION GetItemRect (BYVAL hToolbar AS HWND, BYVAL nButton AS LONG, BYREF rc AS RECT) AS BOOLEAN
FUNCTION GetItemRect (BYVAL hToolbar AS HWND, BYVAL nButton AS LONG) AS RECT
ParameterDescription
hToolbarHandle to the toolbar control.
nButtonZero-based index of the button for which to retrieve information.
prcPointer to a RECT structure that receives the client coordinates of the bounding rectangle.
rcA RECT structure that receives the client coordinates of the bounding rectangle.
Return value

Returns TRUE if successful, or FALSE otherwise.

Remarks

This message does not retrieve the bounding rectangle for buttons whose state is set to the TBSTATE_HIDDEN value.


GetMaxSize

Retrieves the total size of all of the visible buttons and separators in the toolbar.

FUNCTION GetMaxSize (BYVAL hToolbar AS HWND, BYVAL psize AS SIZE PTR) AS BOOLEAN
FUNCTION GetMaxSize (BYVAL hToolbar AS HWND, BYREF sz AS SIZE) AS BOOLEAN
FUNCTION GetMaxSize (BYVAL hToolbar AS HWND) AS SIZE
ParameterDescription
hToolbarHandle to the toolbar control.
psizePointer to a SIZE structure that receives the size of the items.
szA SIZE structure that receives the size of the items.
Return value

Returns nonzero if successful, or zero otherwise.


GetMetrics

Retrieves the metrics of a toolbar control.

SUB GetMetrics (BYVAL hToolbar AS HWND, BYVAL ptbMetrics AS TBMETRICS PTR)
SUB GetMetrics (BYVAL hToolbar AS HWND, BYREF tbMet AS TBMETRICS)
FUNCTION GetMetrics (BYVAL hToolbar AS HWND) AS TBMETRICS
ParameterDescription
hToolbarHandle to the toolbar control.
ptbMetricsPointer to a TBMETRICS structure that receives the toolbar metrics.
tbMetricsA TBMETRICS structure that receives the toolbar metrics.
Note

To use this message, you must provide a manifest specifying Comclt32.dll version 6.0.


GetObject

Retrieves a pointer to the IDropTarget interface for a toolbar control.

FUNCTION GetObject (BYVAL hToolbar AS HWND) AS IDropTarget PTR
ParameterDescription
hToolbarHandle to the toolbar control.
Remarks

The toolbar's IDropTarget is used by the toolbar when objects are dragged over or dropped onto it.


GetRect

Retrieves the bounding rectangle for a specified toolbar button.

FUNCTION GetRect (BYVAL hToolbar AS HWND, BYVAL iID AS LONG, BYVAL prc AS RECT PTR) AS BOOLEAN
FUNCTION GetRect (BYVAL hToolbar AS HWND, BYVAL iID AS LONG, BYREF rc AS RECT) AS BOOLEAN
FUNCTION GetRect (BYVAL hToolbar AS HWND, BYVAL iID AS LONG) AS RECT
ParameterDescription
hToolbarHandle to the toolbar control.
iIDCommand identifier of the button.
prcPointer to a RECT structure that will receive the bounding rectangle information.
rcA RECT structure that will receive the bounding rectangle information.
Remarks

Returns nonzero if successful, or zero otherwise.

Remarks

This message does not retrieve the bounding rectangle for buttons whose state is set to the TBSTATE_HIDDEN value.


GetRows

Retrieves the number of rows of buttons in a toolbar with the TBSTYLE_WRAPABLE style.

FUNCTION GetRows (BYVAL hToolbar AS HWND) AS DWORD
ParameterDescription
hToolbarHandle to the toolbar control.
Remarks

Returns the number of rows.


GetState

Retrieves information about the state of the specified button in a toolbar, such as whether it is enabled, pressed, or checked.

FUNCTION GetState (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG) AS DWORD
ParameterDescription
hToolbarHandle to the toolbar control.
idButtonCommand identifier of the button for which to retrieve information.
Remarks

Returns the button state information if successful, or -1 otherwise. The button state information can be a combination of the values listed in Toolbar Button States.


GetString

Retrieves a string from a toolbar's string pool.

FUNCTION GetString (BYVAL hToolbar AS HWND, BYVAL iString AS SHORT, _
   BYVAL pBuffer AS WSTRING PTR, BYVAL cchMax AS SHORT) AS LONG
ParameterDescription
hToolbarHandle to the toolbar control.
iStringThe index of the string.
pBufferPointer to a buffer used to return the string.
cchMaxThe he length of the lParam buffer.
Return value

Returns the string length if successful, or -1 otherwise.

Remarks

This message returns the specified string from the toolbar's string pool. It does not necessarily correspond to the text string currently being displayed by a button. To retrieve a button's current text string, call the GetButtonText method.


GetStyle

Retrieves the styles currently in use for a toolbar control.

FUNCTION GetStyle (BYVAL hToolbar AS HWND) AS DWORD
ParameterDescription
hToolbarHandle to the toolbar control.
Remarks

Returns a DWORD value that is a combination of toolbar control styles.


GetTextRows

Retrieves the maximum number of text rows that can be displayed on a toolbar button.

FUNCTION GetTextRows (BYVAL hToolbar AS HWND) AS DWORD
ParameterDescription
hToolbarHandle to the toolbar control.
Remarks

Returns an INT value representing the maximum number of text rows that the control will display for a button.


GetTooltips

Retrieves the handle to the tooltip control, if any, associated with the toolbar.

FUNCTION GetTooltips (BYVAL hToolbar AS HWND) AS HWND
ParameterDescription
hToolbarHandle to the toolbar control.
Return value

Returns the handle to the tooltip control, or NULL if the toolbar has no associated tooltip.


HideButton

Hides or shows the specified button in a toolbar.

FUNCTION HideButton (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG, BYVAL fShow AS SHORT) AS BOOLEAN
FUNCTION HideButton (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG) AS BOOLEAN
FUNCTION UnhideButton (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG) AS BOOLEAN
ParameterDescription
hToolbarHandle to the toolbar control.
idButtonCommand identifier of the button to hide or show.
fShowTRUE to hidden the button or FALSE to show it.
Return value

Returns TRUE if successful, or FALSE otherwise.


HighlightButton

Sets the highlight state of a given button in a toolbar control.

FUNCTION HighlightButton (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG) AS BOOLEAN
FUNCTION UnhighlightButton (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG) AS BOOLEAN
ParameterDescription
hToolbarHandle to the toolbar control.
idButtonCommand identifier for a toolbar button.
Return value

Returns TRUE if successful, or FALSE otherwise.


HitTest

Determines where a point lies in a toolbar control.

FUNCTION HitTest (BYVAL hToolbar AS HWND, BYVAL pptHitTest AS POINT PTR) AS LONG
FUNCTION HitTest (BYVAL hToolbar AS HWND, BYREF ptHitTest AS POINT) AS LONG
FUNCTION HitTest (BYVAL hToolbar AS HWND) AS POINT
ParameterDescription
hToolbarHandle to the toolbar control.
pptHitTestPointer to a POINT structure that contains the x-coordinate of the hit test in the x member and the y-coordinate of the hit test in the y member. The coordinates are relative to the toolbar's client area.
ptHitTestA POINT structure that contains the x-coordinate of the hit test in the x member and the y-coordinate of the hit test in the y member. The coordinates are relative to the toolbar's client area.
Return value

Returns an integer value. If the return value is zero or a positive value, it is the zero-based index of the nonseparator item in which the point lies. If the return value is negative, the point does not lie within a button. The absolute value of the return value is the index of a separator item or the nearest nonseparator item.


Indeterminate

Sets or clears the indeterminate state of the specified button in a toolbar.

FUNCTION Indeterminate (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG, BYVAL fIndeterminate AS SHORT) AS BOOLEAN
ParameterDescription
hToolbarHandle to the toolbar control.
idButtonCommand identifier of the button whose indeterminate state is to be set or cleared.
fIndeterminateTRUE to set the indeterminate state or FALSE to clear it.
Return value

Returns TRUE if successful, or FALSE otherwise.


InsertButton

Inserts a button in a toolbar.

FUNCTION InsertButton (BYVAL hToolbar AS HWND, BYVAL idxButton AS LONG, BYVAL pButton AS TBBUTTON PTR) AS BOOLEAN
FUNCTION InsertButton (BYVAL hToolbar AS HWND, BYVAL idxButton AS LONG, BYREF Button AS TBBUTTON) AS BOOLEAN
FUNCTION InsertButton (BYVAL hToolbar AS HWND, BYVAL idxButton AS LONG, BYVAL idxBitmap AS LONG, _
   BYVAL idCommand AS LONG, BYVAL fsState AS UBYTE = 0, BYVAL fsStyle AS UBYTE = 0, BYVAL dwData AS DWORD_PTR = 0, _
   BYVAL pwszText AS WSTRING PTR = NULL) AS BOOLEAN
ParameterDescription
hToolbarHandle to the toolbar control.
idxButtonZero-based index of a button. The message inserts the new button to the left of this button.
pButtonPointer to a TBBUTTON structure containing information about the button to insert.
ButtonA TBBUTTON structure containing information about the button to insert.
idxBitmapZero-based index of the button image. Set this member to I_IMAGECALLBACK, and the toolbar will send the TBN_GETDISPINFO notification code to retrieve the image index when it is needed.
idCommandCommand identifier associated with the button. This identifier is used in a WM_COMMAND message when the button is chosen.
fsStateButton state flags. This member can be a combination of the values listed in Toolbar Button States.
fsStyleButton style. This member can be a combination of the button style values listed in Toolbar Control and Button Styles.
dwDataApplication-defined value.
pwszTextPointer to a string buffer that contains text for the button.

InsertMarkHitTest

Retrieves the insertion mark information for a point in a toolbar.

FUNCTION InsertMarkHitTest (BYVAL hToolbar AS HWND, BYVAL ppt AS POINT PTR, BYVAL ptbim AS TBINSERTMARK PTR) AS BOOLEAN
FUNCTION InsertMarkHitTest (BYVAL hToolbar AS HWND, BYREF pt AS POINT, BYVAL tbim AS TBINSERTMARK) AS BOOLEAN
ParameterDescription
hToolbarHandle to the toolbar control.
pptPointer to a POINT structure that contains the hit test coordinates, relative to the client area of the toolbar.
ptA POINT structure that contains the hit test coordinates, relative to the client area of the toolbar.
ptbimPointer to a TBINSERTMARK structure that receives the insertion mark information.
tbimA TBINSERTMARK structure that receives the insertion mark information.
Return value

Returns nonzero if the point is an insertion mark, or zero otherwise.


InsertSeparator

Inserts a separator in a toolbar.

FUNCTION InsertSeparator (BYVAL hToolbar AS HWND, BYVAL idxButton AS LONG, BYVAL nWidth AS LONG = 0) AS BOOLEAN
ParameterDescription
hToolbarHandle to the toolbar control.
idxButtonZero-based index of a button. The message inserts the new separator to the left of this button.
nWidthWidth of the separator, in pixels
Return value

Returns TRUE if successful, or FALSE otherwise.


IsButtonChecked

Determines whether the specified button in a toolbar is checked.

FUNCTION IsButtonChecked (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG) AS LONG
ParameterDescription
hToolbarHandle to the toolbar control.
idButtonCommand identifier of the button.
Return value

Returns nonzero if the button is checked, or zero otherwise.


IsButtonEnabled

Determines whether the specified button in a toolbar is enabled.

FUNCTION IsButtonEnabled (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG) AS LONG
ParameterDescription
hToolbarHandle to the toolbar control.
idButtonCommand identifier of the button.
Return value

Returns nonzero if the button is enabled, or zero otherwise.


IsButtonHidden

Determines whether the specified button in a toolbar is hidden.

FUNCTION IsButtonHidden (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG) AS LONG
ParameterDescription
hToolbarHandle to the toolbar control.
idButtonCommand identifier of the button.
Return value

Returns nonzero if the button is hidden, or zero otherwise.


IsButtonHighlighted

Checks the highlight state of a toolbar button.

FUNCTION IsButtonHighlighted (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG) AS LONG
ParameterDescription
hToolbarHandle to the toolbar control.
idButtonCommand identifier of the button.
Return value

Returns nonzero if the button is highlighted, or zero otherwise.


IsButtonIndeterminate

Determines whether the specified button in a toolbar is indeterminate.

FUNCTION IsButtonIndeterminate (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG) AS LONG
ParameterDescription
hToolbarHandle to the toolbar control.
idButtonCommand identifier of the button.
Return value

Returns nonzero if the button is indeterminate, or zero otherwise.


IsButtonPressed

Determines whether the specified button in a toolbar is pressed.

FUNCTION IsButtonPressed (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG) AS LONG
ParameterDescription
hToolbarHandle to the toolbar control.
idButtonCommand identifier of the button.
Return value

Returns nonzero if the button is pressed, or zero otherwise.


LoadImages

Loads system-defined button images into a toolbar control's image list.

FUNCTION LoadImages (BYVAL hToolbar AS HWND, BYVAL iBitmapID AS DWORD, BYVAL hinst AS HINSTANCE) AS LONG
FUNCTION LoadImages (BYVAL hToolbar AS HWND, BYVAL iBitmapID AS DWORD) AS LONG
ParameterDescription
hToolbarHandle to the toolbar control.
iBitmapIDIdentifier of a system-defined button image list. This parameter can be set to one of the following values (see below).
hInstInstance handle. This parameter must be set to HINST_COMMCTRL.
ValueMeaning
IDB_HIST_LARGE_COLORWindows Explorer bitmaps in large size.
IDB_HIST_SMALL_COLORWindows Explorer bitmaps in small size.
IDB_STD_LARGE_COLORStandard bitmaps in large size.
IDB_STD_SMALL_COLORStandard bitmaps in small size.
IDB_VIEW_LARGE_COLORView bitmaps in large size.
IDB_VIEW_SMALL_COLORView bitmaps in small size.
IDB_HIST_NORMALWindows Explorer travel buttons and favorites bitmaps in normal state.
IDB_HIST_HOTWindows Explorer travel buttons and favorites bitmaps in hot state.
IDB_HIST_DISABLEDWindows Explorer travel buttons and favorites bitmaps in disabled state.
IDB_HIST_PRESSEDWindows Explorer travel buttons and favorites bitmaps in pressed state.
Return value

The count of images in the image list. Returns zero if the toolbar has no image list or if the existing image list is empty.

Remarks

You must use the proper image index values when you prepare TBBUTTON structures prior to sending the TB_ADDBUTTONSW message. For a list of image index values for these preset bitmaps, see Toolbar Standard Button Image Index Values.


MakeOpaque

Makes the toolbar opaque by removing the TBSTYLE_TRANSPARENT style.

SUB MakeOpaque (BYVAL hToolbar AS HWND)
ParameterDescription
hToolbarHandle to the toolbar control.

MapAccelerator

Determines the ID of the button that corresponds to the specified accelerator character.

FUNCTION MapAccelerator (BYVAL hToolbar AS HWND, BYVAL chAccel AS DWORD, BYVAL pIDBtn AS DWORD PTR) AS BOOLEAN
FUNCTION MapAccelerator (BYVAL hToolbar AS HWND, BYVAL chAccel AS DWORD, BYREF IDBtn AS DWORD) AS BOOLEAN
FUNCTION MapAccelerator (BYVAL hToolbar AS HWND, BYVAL chAccel AS DWORD) AS DWORD
ParameterDescription
hToolbarHandle to the toolbar control.
chAccelThe accelerator character.
IDBtnPointer to a DWORD. On return, if successful, this parameter will hold the id of the button that has chAccel as its accelerator character.
IDBtnA DWORD. On return, if successful, this parameter will hold the id of the button that has chAccel as its accelerator character.
Return value

Returns a nonzero value if one of the buttons has chAccel as its accelerator character, or zero otherwise.


MarkButton

Sets the highlight state of a given button in a toolbar control.

FUNCTION MarkButton (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG, BYVAL fHighlight AS SHORT) AS BOOLEAN
ParameterDescription
hToolbarHandle to the toolbar control.
idButtonCommand identifier for a toolbar button.
fHighlightTRUE to highlight the button; FALSE to set the button to its default state.
Return value

Returns TRUE if successful, or FALSE otherwise.


MoveButton

Moves a button from one index to another.

FUNCTION MoveButton (BYVAL hToolbar AS HWND, BYVAL uOldPos AS DWORD, BYVAL uNewPos AS DWORD) AS BOOLEAN
ParameterDescription
hToolbarHandle to the toolbar control.
uOldPosZero-based index of the button to be moved.
uNewPosZero-based index where the button will be moved.
Return value

Returns TRUE if successful, or FALSE otherwise.


PressButton

Presses or releases the specified button in a toolbar.

FUNCTION PressButton (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG, BYVAL fPress AS SHORT) AS BOOLEAN
FUNCTION PressButton (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG) AS BOOLEAN
FUNCTION ReleaseButton (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG) AS BOOLEAN
ParameterDescription
hToolbarHandle to the toolbar control.
idButtonCommand identifier of the button to press or release.
fPressIf TRUE, the button is pressed. If FALSE, the button is released.
Return value

Returns TRUE if successful, or FALSE otherwise.


RemoveDarkMode

Removes the toolbar dark mode.

FUNCTION RemoveDarkMode (BYVAL hToolbar AS HWND) AS HRESULT
ParameterDescription
hToolbarHandle to the toolbar control.
Return value

If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.


ReplaceBitmap

Replaces an existing bitmap with a new bitmap.

FUNCTION ReplaceBitmap (BYVAL hToolbar AS HWND, BYVAL ptbrb AS TBREPLACEBITMAP PTR) AS BOOLEAN
FUNCTION ReplaceBitmap (BYVAL hToolbar AS HWND, BYREF tbrb AS TBREPLACEBITMAP) AS BOOLEAN
ParameterDescription
hToolbarHandle to the toolbar control.
ptbrbPointer to a TBREPLACEBITMAP structure that contains the information of the bitmap to be replaced and the new bitmap.
tbrbA TBREPLACEBITMAP structure that contains the information of the bitmap to be replaced and the new bitmap.
Return value

Returns TRUE if successful, or FALSE otherwise.


SaveRestore

Send this message to initiate saving or restoring a toolbar state.

SUB SaveRestore (BYVAL hToolbar AS HWND, BYVAL fSave AS LONG, BYVAL ptbsp AS TBSAVEPARAMSW PTR)
SUB SaveRestore (BYVAL hToolbar AS HWND, BYVAL fSave AS LONG, BYREF tbsp AS TBSAVEPARAMSW)
ParameterDescription
hToolbarHandle to the toolbar control.
fSaveSave or restore flag. If this parameter is TRUE, the information is saved. If it is FALSE, the information is restored.
ptbspPointer to a TBSAVEPARAMS structure that specifies the registry key, subkey, and value name for the toolbar state information.
tbspA TBSAVEPARAMS structure that specifies the registry key, subkey, and value name for the toolbar state information.

SetAnchorHighlight

Sets the anchor highlight setting for a toolbar.

FUNCTION SetAnchorHighlight (BYVAL hToolbar AS HWND, BYVAL fAnchor AS BOOLEAN) AS BOOLEAN
ParameterDescription
hToolbarHandle to the toolbar control.
fAnchorBOOL value that specifies if anchor highlighting is enabled or disabled. If this value is nonzero, anchor highlighting will be enabled. If this value is zero, anchor highlighting will be disabled.
Return value

Returns the previous anchor highlight setting. If this value is nonzero, anchor highlighting was enabled. If this value is zero, anchor highlighting was disabled.

Remarks

Anchor highlighting in a toolbar means that the last highlighted item will remain highlighted until another item is highlighted. This occurs even if the cursor leaves the toolbar control.


SetBitmapSize

Sets the size of the bitmapped images to be added to a toolbar.

FUNCTION SetBitmapSize (BYVAL hToolbar AS HWND, BYVAL dxBitmap AS SHORT, BYVAL dyBitmap AS SHORT) AS BOOLEAN
ParameterDescription
hToolbarHandle to the toolbar control.
dxBitmapThe width, in pixels, of the bitmapped images.
dyBitmapThe height, in pixels, of the bitmapped images.
Return value

Returns TRUE if successful, or FALSE otherwise.

Remarks

The size can be set only before adding any bitmaps to the toolbar. If an application does not explicitly set the bitmap size, the size defaults to 16 by 15 pixels.


SetButtonInfo

Sets the information for an existing button in a toolbar.

FUNCTION SetButtonInfo (BYVAL hToolbar AS HWND, BYVAL iID AS LONG, BYVAL ptbbi AS TBBUTTONINFOW PTR) AS LONG
FUNCTION SetButtonInfo (BYVAL hToolbar AS HWND, BYVAL iID AS LONG, BYREF tbbi AS TBBUTTONINFOW) AS LONG
ParameterDescription
hToolbarHandle to the toolbar control.
iIDButton identifier.
ptbbiPointer to a TBBUTTONINFO structure that contains the new button information. The cbSize and dwMask members of this structure must be filled in prior to sending this message.
tbbiA TBBUTTONINFO structure that contains the new button information. The cbSize and dwMask members of this structure must be filled in prior to sending this message.
Return value

Returns nonzero if successful, or zero otherwise.

Remarks

Text is commonly assigned to buttons when they are added to a toolbar by specifying the index of a string in the toolbar's string pool. If you use a TB_SETBUTTONINFO to assign new text to a button, it will permanently override the text from the string pool. You can change the text by calling TB_SETBUTTONINFO again, but you cannot reassign the string from the string pool


SetButtonSize

Sets the size of buttons on a toolbar.

FUNCTION SetButtonSize (BYVAL hToolbar AS HWND, BYVAL dxButton AS SHORT, BYVAL dyButton AS SHORT) AS BOOLEAN
ParameterDescription
hToolbarHandle to the toolbar control.
dxButtonThe width, in pixels, of the buttons.
dyButtonThe height, in pixels, of the buttons.
Return value

Returns TRUE if successful, or FALSE otherwise.


SetButtonWidth

Sets the minimum and maximum button widths in the toolbar control.

FUNCTION SetButtonWidth (BYVAL hToolbar AS HWND, BYVAL cxMin AS SHORT, BYVAL cxMax AS SHORT) AS BOOLEAN
ParameterDescription
hToolbarHandle to the toolbar control.
cxMinThe minimum button width, in pixels. Toolbar buttons will never be narrower than this value.
cxMaxThe maximum button width, in pixels. If button text is too wide, the control displays it with ellipsis points.
Return value

Returns TRUE if successful, or FALSE otherwise.


SetCmdId

Sets the command identifier of a toolbar button.

FUNCTION SetCmdId (BYVAL hToolbar AS HWND, BYVAL index AS SHORT, BYVAL cmdid AS SHORT) AS BOOLEAN
ParameterDescription
hToolbarHandle to the toolbar control.
indexZero-based index of the button whose command identifier is to be set.
cmdidCommand identifier.
Return value

Returns TRUE if successful, or FALSE otherwise.


SetColorScheme

Sets the color scheme information for the toolbar control.

SUB SetColorScheme (BYVAL hToolbar AS HWND, BYVAL pcs AS COLORSCHEME PTR)
SUB SetColorScheme (BYVAL hToolbar AS HWND, BYREF cs AS COLORSCHEME)
ParameterDescription
hToolbarHandle to the toolbar control.
pcsPointer to a COLORSCHEME structure that contains the color scheme information.
csA COLORSCHEME structure that contains the color scheme information.
Return value

Returns TRUE if successful, or FALSE otherwise.


SetDarkMode

Sets the toolbar dark mode.

FUNCTION SetDarkMode (BYVAL hToolbar AS HWND) AS HRESULT
ParameterDescription
hToolbarHandle to the toolbar control.
Return value

If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.


SetDisabledImageList

Sets the image list that the toolbar control will use to display disabled buttons.

FUNCTION SetDisabledImageList (BYVAL hToolbar AS HWND, BYVAL himlNewDisabled AS HIMAGELIST) AS HIMAGELIST
ParameterDescription
hToolbarHandle to the toolbar control.
himlNewDisabledHandle to the image list that will be set.
Return value

Returns the handle to the image list previously used to display disabled buttons, or NULL if no image list was previously set.


SetDrawTextFlags

Sets the text drawing flags for the toolbar.

FUNCTION SetDrawTextFlags (BYVAL hToolbar AS HWND, BYVAL dwMask AS DWORD, BYVAL dwDTFlags AS DWORD) AS DWORD
ParameterDescription
hToolbarHandle to the toolbar control.
dwMaskOne or more of the DT_ flags, specified in DrawText, that indicate which bits in dwDTFlags will be used when drawing the text.
dwDTFlagsOne or more of the DT_ flags, specified in DrawText, that indicate how the button text will be drawn. This value will be passed to the DrawText function when the button text is drawn.
Return value

Returns the previous text drawing flags.

Remarks

The dwMask parameter allows you to specify which flags will be used when drawing the text, even if these flags are turned off. For example, if you do not want the DT_CENTER flag used when drawing text, you would add the DT_CENTER flag to dwMask and not specify the DT_CENTER flag in dwDTFlags. This prevents the control from passing the DT_CENTER flag to the DrawText function.


SetExtendedStyle

Sets the extended styles for a toolbar control.

FUNCTION SetExtendedStyle (BYVAL hToolbar AS HWND, BYVAL dwExStyle AS DWORD) AS DWORD
ParameterDescription
hToolbarHandle to the toolbar control.
dwExStyleValue specifying the new extended styles. This parameter can be a combination of extended styles.
Return value

Returns a DWORD that represents the previous extended styles. This value can be a combination of extended styles.


SetHotImageList

Sets the image list that the toolbar control will use to display hot buttons.

FUNCTION SetHotImageList (BYVAL hToolbar AS HWND, BYVAL himlNewHot AS HIMAGELIST) AS HIMAGELIST
ParameterDescription
hToolbarHandle to the toolbar control.
himlNewHotHandle to the image list that will be set.
Return value

Returns the handle to the image list previously used to display hot buttons, or NULL if no image list was previously set.

Remarks

A button is hot when the cursor is over it. Toolbar controls must have the TBSTYLE_FLAT or TBSTYLE_LIST style to have hot items.


SetHotItem

Sets the hot item in a toolbar.

FUNCTION SetHotItem (BYVAL hToolbar AS HWND, BYVAL iHot AS LONG) AS LONG
ParameterDescription
hToolbarHandle to the toolbar control.
iHotIndex of the item that will be made hot. If this value is -1, none of the items will be hot.
Return value

Returns the index of the previous hot item, or -1 if there was no hot item.

Remarks

The behavior of this message is not defined for toolbars that do not have the TBSTYLE_FLAT style.


SetImageList

Sets the image list that the toolbar uses to display buttons that are in their default state.

FUNCTION SetImageList (BYVAL hToolbar AS HWND, BYVAL himlNew AS HIMAGELIST) AS HIMAGELIST
ParameterDescription
hToolbarHandle to the toolbar control.
himlNewHandle to the image list to set. If this parameter is NULL, no images are displayed in the buttons.
Return value

Returns the handle to the image list previously used to display buttons in their default state, or NULL if no image list was previously set.

Remarks

Your application is responsible for freeing the image list after the toolbar is destroyed.

The TB_SETIMAGELIST message cannot be combined with TB_ADDBITMAP. It also cannot be used with toolbars created with CreateToolbarEx, which calls TB_ADDBITMAP internally. When you create a toolbar with CreateToolbarEx or use TB_ADDBITMAP to add images, the toolbar manages the image list internally. Attempting to modify it with TB_SETIMAGELIST has unpredictable consequences.


SetIndent

Sets the indentation for the first button in a toolbar control.

FUNCTION SetIndent (BYVAL hToolbar AS HWND, BYVAL iIndent AS LONG) AS BOOLEAN
ParameterDescription
hToolbarHandle to the toolbar control.
iIndentValue specifying the indentation, in pixels.
Return value

If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.


SetInsertMark

Sets the current insertion mark for the toolbar.

SUB SetInsertMark (BYVAL hToolbar AS HWND, BYVAL ptbim AS TBINSERTMARK PTR)
SUB SetInsertMark (BYVAL hToolbar AS HWND, BYREF tbim AS TBINSERTMARK)
ParameterDescription
hToolbarHandle to the toolbar control.
ptbimPointer to a TBINSERTMARK structure that contains the insertion mark.
tbimA TBINSERTMARK structure that contains the insertion mark.

SetInsertMarkColor

Sets the color used to draw the insertion mark for the toolbar.

FUNCTION SetInsertMarkColor (BYVAL hToolbar AS HWND, BYVAL clrInsertMark AS COLORREF) AS COLORREF
ParameterDescription
hToolbarHandle to the toolbar control.
clrInsertMarkCOLORREF value that contains the new insertion mark color.
Return value

Returns a COLORREF value that contains the previous insertion mark color.


SetListGap

Sets the distance between the toolbar buttons on a specific toolbar.

SUB SetListGap (BYVAL hToolbar AS HWND, BYVAL gap AS DWORD)
ParameterDescription
hToolbarHandle to the toolbar control.
gapThe gap, in pixels, between buttons on the toolbar.
Remarks

The gap between buttons only applies to the toolbar control window that receives this message. Receipt of this message triggers a repaint of the toolbar, if the toolbar is currently visible.


SetMaxTextRows

Sets the maximum number of text rows displayed on a toolbar button.

FUNCTION SetMaxTextRows (BYVAL hToolbar AS HWND, BYVAL iMaxRows AS LONG) AS BOOLEAN
ParameterDescription
hToolbarHandle to the toolbar control.
iMaxRowsMaximum number of rows of text that can be displayed.
Return value

If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

To cause text to wrap, you must set the maximum button width by sending a TB_SETBUTTONWIDTH message. The text wraps at a word break; line breaks ("\n") in the text are ignored. Text in TBSTYLE_LIST toolbars is always shown on a single line.


SetMetrics

Sets the metrics of a toolbar control.

SUB SetMetrics (BYVAL hToolbar AS HWND, BYVAL ptbMetrics AS TBMETRICS PTR)
SUB SetMetrics (BYVAL hToolbar AS HWND, BYREF tbMet AS TBMETRICS)
ParameterDescription
hToolbarHandle to the toolbar control.
ptbMetricsPointer to a TBMETRICS structure that contains the toolbar metrics to set.
tbMetA TBMETRICS structure that contains the toolbar metrics to set.
Remarks

To use this message, you must provide a manifest specifying Comclt32.dll version 6.0.


SetPadding

Sets the padding for a toolbar control.

FUNCTION SetPadding (BYVAL hToolbar AS HWND, BYVAL cx AS SHORT, BYVAL cy AS SHORT) AS DWORD
ParameterDescription
hToolbarHandle to the toolbar control.
cxThe horizontal padding, in pixels.
cyThe vertical padding, in pixels.
Return value

Returns a DWORD value that contains the previous horizontal padding in the LOWORD and the previous vertical padding in the HIWORD, in pixels.

Remarks

The padding values are used to create a blank area between the edge of the button and the button's image and/or text. Where and how much padding is actually applied depends on the type of the button and whether it has an image. The horizontal padding is applied to both the right and left of the button, and the vertical padding is applied to both the top and bottom of the button. Padding is only applied to buttons that have the TBSTYLE_AUTOSIZE style.


SetParent

Sets the window to which the toolbar control sends notification messages.

FUNCTION SetParent (BYVAL hToolbar AS HWND, BYVAL hwndParent AS HWND) AS HWND
ParameterDescription
hToolbarHandle to the toolbar control.
hwndParentHandle to the window to receive notification messages.
Return value

The return value is a handle to the previous notification window, or NULL if there is no previous notification window.

Remarks

The TB_SETPARENT message does not change the parent window that was specified when the control was created. Calling the GetParent function for a toolbar control will return the actual parent window, not the window specified in TB_SETPARENT. To change the control's parent window, call the SetParent function.


SetPressedImageList

Sets the image list that the toolbar uses to display buttons that are in a pressed state.

FUNCTION SetPressedImageList (BYVAL hToolbar AS HWND, BYVAL iImageID AS DWORD, BYVAL himlNew AS HIMAGELIST) AS HIMAGELIST
ParameterDescription
hToolbarHandle to the toolbar control.
iImageIDThe index of the image list. If you use only one image list, set this parameter to zero.
himlNewHandle to the image list to set. If this parameter is NULL, no images are displayed in the buttons.
Return value

Returns the handle to the image list previously used to display buttons in their pressed state, or NULL if no such image list was previously set.

Remarks

Your application is responsible for freeing the image list after the toolbar is destroyed.

The TB_SETPRESSEDIMAGELIST message cannot be combined with TB_ADDBITMAP. It also cannot be used with toolbars created with CreateToolbarEx, which calls TB_ADDBITMAP internally. When you create a toolbar with CreateToolbarEx or use TB_ADDBITMAP to add images, the toolbar manages the image list internally. Attempting to modify it with TB_SETPRESSEDIMAGELIST has unpredictable consequences.


SetRows

Sets the number of rows of buttons in a toolbar.

SUB SetRows (BYVAL hToolbar AS HWND, BYVAL cRows AS WORD, BYVAL fLarger AS BOOLEAN, BYVAL prc AS RECT PTR)
SUB SetRows (BYVAL hToolbar AS HWND, BYVAL cRows AS WORD, BYVAL fLarger AS BOOLEAN, BYREF rc AS RECT)
ParameterDescription
hToolbarHandle to the toolbar control.
cRowsThe number of rows requested. The minimum number of rows is one, and the maximum number of rows is equal to the number of buttons in the toolbar
fLargerIndicates whether to create more rows than requested when the system cannot create the number of rows specified by wParam. If TRUE, the system creates more rows. If FALSE, the system creates fewer rows.
prcPointer to a RECT structure that receives the bounding rectangle of the toolbar after the rows are set.
rcA RECT structure that receives the bounding rectangle of the toolbar after the rows are set.
Remarks

Because the system does not break up button groups when setting the number of rows, the resulting number of rows might differ from the number requested.


SetState

Sets the state for the specified button in a toolbar.

FUNCTION SetState (BYVAL hToolbar AS HWND, BYVAL idButton AS LONG, BYVAL fState AS SHORT) AS BOOLEAN
ParameterDescription
hToolbarHandle to the toolbar control.
idButtonCommand identifier of the button.
fStateA is a combination of values listed in Toolbar Button States.
Return value

Returns TRUE if successful, or FALSE otherwise.


SetStyle

Sets the style for a toolbar control.

SUB SetStyle (BYVAL hToolbar AS HWND, BYVAL dwStyle AS DWORD)
ParameterDescription
hToolbarHandle to the toolbar control.
dwStyleValue specifying the styles to be set for the control. This value can be a combination of toolbar control styles.
Return value

Returns TRUE if successful, or FALSE otherwise.


SetToolTips

Associates a tooltip control with a toolbar.

SUB SetToolTips (BYVAL hToolbar AS HWND, BYVAL hwndToolTip AS HWND)
ParameterDescription
hToolbarHandle to the toolbar control.
hwndToolTipHandle to the tooltip control.
Remarks

Any buttons added to a toolbar before sending the TB_SETTOOLTIPS message will not be registered with the tooltip control.


SetWindowTheme

Sets the visual style of a toolbar control.

SUB SetWindowTheme (BYVAL hToolbar AS HWND, BYVAL pwszTheme AS WSTRING PTR)
ParameterDescription
hToolbarHandle to the toolbar control.
pwszThemePointer to a Unicode string that contains the toolbar visual style to set.
Remarks

To use this message, you must provide a manifest specifying Comclt32.dll version 6.0.

Sending this message is equivalent to calling SetWindowTheme on the toolbar and its tooltip control, if any.