mensaje de TB_ADDBUTTONS

Agrega uno o varios botones a una barra de herramientas.

Parámetros

wParam

Número de botones a agregar.

lParam

Puntero a una matriz de estructuras TBBUTTON que contienen información sobre los botones que se van a agregar. Debe haber el mismo número de elementos en la matriz que los botones especificados por wParam.

Valor devuelto

Devuelve TRUE si se ejecuta correctamente o FALSE de lo contrario.

Comentarios

Si la barra de herramientas se creó con la función CreateWindowEx , debe enviar el mensaje TB_BUTTONSTRUCTSIZE a la barra de herramientas antes de enviar TB_ADDBUTTONS.

Consulte TB_SETIMAGELIST para obtener información sobre cómo asignar mapas de bits a botones de barra de herramientas de una o varias listas de imágenes.

Ejemplos

El código de ejemplo siguiente agrega tres botones a una barra de herramientas mediante el mapa de bits estándar del sistema para los botones de vista. El mensaje TB_ADDBITMAP devuelve el índice de la primera imagen de botón dentro de la lista de imágenes. Las imágenes individuales se identifican mediante sus desplazamientos de ese valor.

TBADDBITMAP tbAddBitmap;
tbAddBitmap.hInst = HINST_COMMCTRL;
tbAddBitmap.nID = IDB_VIEW_SMALL_COLOR;

// There are 12 items in IDB_VIEW_SMALL_COLOR.  However, because this is a standard
// system-defined bitmap, the wParam (nButtons) is ignored.
//
// hWndToolbar is the handle of the toolbar window.
//
// Do not forget to send TB_BUTTONSTRUCTSIZE if the toolbar was created
// by using CreateWindowEx.
//
int stdidx = SendMessage(hWndToolbar, TB_ADDBITMAP, 0, (LPARAM)&tbAddBitmap);

// Define the buttons. 
// IDM_SETLARGEICONVIEW and so on are application-defined command IDs.

const int numButtons = 3;
TBBUTTON tbButtonsAdd[numButtons] = 
{
    {stdidx + VIEW_LARGEICONS, IDM_SETLARGEICONVIEW, TBSTATE_ENABLED, BTNS_BUTTON},
    {stdidx + VIEW_SMALLICONS, IDM_SETSMALLICONVIEW, TBSTATE_ENABLED, BTNS_BUTTON},
    {stdidx + VIEW_DETAILS, IDM_SETDETAILSVIEW, TBSTATE_ENABLED, BTNS_BUTTON}
}; 

// Add the view buttons.
SendMessage(hWndToolbar, TB_ADDBUTTONS, numButtons, (LPARAM)tbButtonsAdd);

Requisitos

Requisito Value
Cliente mínimo compatible
Windows Vista [solo aplicaciones de escritorio]
Servidor mínimo compatible
Windows Server 2003 [solo aplicaciones de escritorio]
Encabezado
Commctrl.h
Nombres Unicode y ANSI
TB_ADDBUTTONSW (Unicode) y TB_ADDBUTTONSA (ANSI)

Consulte también

Valores de índice de imagen de botón estándar de la barra de herramientas