TB_ADDBUTTONS pesan

Menambahkan satu atau beberapa tombol ke bilah alat.

Parameter

wParam

Jumlah tombol yang akan ditambahkan.

lParam

Arahkan ke array struktur TBBUTTON yang berisi informasi tentang tombol yang akan ditambahkan. Harus ada jumlah elemen yang sama dalam array sebagai tombol yang ditentukan oleh wParam.

Mengembalikan nilai

Mengembalikan TRUE jika berhasil, atau FALSE sebaliknya.

Keterangan

Jika toolbar dibuat menggunakan fungsi CreateWindowEx , Anda harus mengirim pesan TB_BUTTONSTRUCTSIZE ke toolbar sebelum mengirim TB_ADDBUTTONS.

Lihat TB_SETIMAGELIST untuk diskusi tentang cara menetapkan bitmap ke tombol toolbar dari satu atau beberapa daftar gambar.

Contoh

Contoh kode berikut menambahkan tiga tombol ke toolbar, menggunakan bitmap sistem standar untuk tombol tampilan. Pesan TB_ADDBITMAP mengembalikan indeks gambar tombol pertama dalam daftar gambar. Gambar individual diidentifikasi oleh offset mereka dari nilai tersebut.

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);

Persyaratan

Persyaratan Nilai
Klien minimum yang didukung
Windows Vista [hanya aplikasi desktop]
Server minimum yang didukung
Windows Server 2003 [hanya aplikasi desktop]
Header
Commctrl.h
Nama Unicode dan ANSI
TB_ADDBUTTONSW (Unicode) dan TB_ADDBUTTONSA (ANSI)

Lihat juga

Bilah Alat Nilai Indeks Gambar Tombol Standar