Code:
_stdcall WinMain(HINSTANCE i, HINSTANCE j, char *k, int l)
{
InitCommonControls();
LoadLibrary("Riched32.dll");
b=CreateDialog(i,(LPCTSTR)"DIALOGO",NULL,(DLGPROC)zzz);
HWND hTool = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, b, (HMENU)45/*ID*/, GetModuleHandle(NULL), NULL);
SendMessage(hTool, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
TBBUTTON tbb[3];
HIMAGELIST hImageList = ImageList_Create(
16, 16, // Dimensions of individual bitmaps.
ILC_COLOR16 | ILC_MASK, // Ensures transparent background.
sizeof(tbb)/sizeof(TBBUTTON), 0);
int custom_icon = ImageList_AddIcon(hImageList, LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_ICO_MAIN)));
SendMessage(hTool, TB_SETIMAGELIST, 0, (LPARAM)hImageList);
SendMessage(hTool, TB_LOADIMAGES, (WPARAM)IDB_STD_SMALL_COLOR, (LPARAM)HINST_COMMCTRL);
ZeroMemory(tbb, sizeof(tbb));
tbb[0].iBitmap = STD_FILENEW;
tbb[0].fsState = TBSTATE_ENABLED;
tbb[0].fsStyle = TBSTYLE_BUTTON;
tbb[0].idCommand = 6002;
tbb[1].iBitmap = STD_FILEOPEN;
tbb[1].fsState = TBSTATE_ENABLED;
tbb[1].fsStyle = TBSTYLE_BUTTON;
tbb[1].idCommand = 6001;
tbb[2].iBitmap = custom_icon;
tbb[2].fsState = TBSTATE_ENABLED;
tbb[2].fsStyle = TBSTYLE_BUTTON | TBSTYLE_DROPDOWN;
tbb[2].idCommand = 453;
SendMessage(b, WM_SIZE, 0, 0);
ShowWindow(b,SW_SHOW);
while (GetMessage(&c,0,0,0)==TRUE)
{
TranslateMessage(&c);
DispatchMessage(&c);
}
}
notice that there is both the loading of an icon in an imagelist and its loading into the toolbar, as well as SendMessage(hTool, TB_LOADIMAGES, (WPARAM)IDB_STD_SMALL_COLOR, (LPARAM)HINST_COMMCTRL); for the loading of the common control icons. the strange thing is that the button that was supposed to display STD_FILENEW displays STD_DELETE instead. when only the common control icons - and not the icons from the imagelist - are loaded into the toolbar, STD_FILENEW is displayed correctly.