Help Center

CToolbar.AddButtonmethod

Adds a button to a toolbar.

WindowsmethodCToolbar.incdocumented

Syntax

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

Parameters

NameDescription
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.

Description

Adds one button to a toolbar.

Remarks

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

Reference

  • Include file CToolbar.inc
  • Defined in AfxNova/CToolbar.inc:235
  • Documented in Windows/WIndows Controls/CToolbar Class.md
  • Topic: CToolbar Class