HIMAGELIST hImageList = 0;
const DWORD buttonStyles = NULL;
//Erstelle Window
hWndToolbar = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD | TBSTYLE_WRAPABLE | TBSTYLE_LIST | CCS_NODIVIDER | CCS_NOPARENTALIGN,
2, 2, 230, 500, hWnd, NULL, (HINSTANCE) hImageList, NULL);
//itemsString[] vorbereiten
...
...
//ImageList erstellen
hImageList = ImageList_Create(24, 24, ILC_COLOR32 | ILC_MASK, quantityFiles, 0);
//Schleife zum hinzufügen mit ImageList_AddIcon()
...
//Set Imagelist
SendMessage(hWndToolbar, TB_SETIMAGELIST, ImageListID, (LPARAM) hImageList);
//Lade Button-Images
SendMessage(hWndToolbar, TB_LOADIMAGES, IDB_STD_LARGE_COLOR, (LPARAM) HINST_COMMCTRL);
//Initialisiere Button-Infos
TBBUTTON *tbButtons = new TBBUTTON[quantityFiles];
//ZeroMemory(&tbButtons, sizeof(tbButtons));
for(int i = 0; i < quantityFiles; i++) {
tbButtons[i].iBitmap = i;
tbButtons[i].idCommand = i+1000;
tbButtons[i].fsState = TBSTATE_ENABLED;
tbButtons[i].fsStyle = buttonStyles;
tbButtons[i].dwData = 0;
tbButtons[i].iString = (INT_PTR) itemsString[i];
}
//Add Buttons
SendMessage(hWndToolbar, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), NULL);
SendMessage(hWndToolbar, TB_ADDBUTTONS, (WPARAM) (const int) (sizeof(tbButtons)/20), (LPARAM) &tbButtons);
SendMessage(hWndToolbar, TB_SETBUTTONSIZE, NULL, MAKELPARAM(230, 32)); //Set size
//Größe ändern und anzeigen
SendMessage(hWndToolbar, TB_AUTOSIZE, NULL, NULL);
ShowWindow(hWndToolbar, TRUE);
//Speicher wieder freigeben
delete[] itemsString;
delete[] tbButtons;