创建toolbar不显示
#include <commctrl.h>
#include "maintoolbar.h"
HWND CreateSimpleToolbar(HWND hWndParent)
{
INITCOMMONCONTROLSEX icex;
icex.dwSize=sizeof(INITCOMMONCONTROLSEX);
icex.dwICC=ICC_BAR_CLASSES;
InitCommonControlsEx(&icex);
HINSTANCE g_hInst=GetModuleHandle(NULL);
const int bitmapSize = 16;
HWND hWndToolbar = CreateWindowEx(0, TOOLBARCLASSNAME, NULL,
WS_CHILD | TBSTYLE_WRAPABLE,
0, 0, 0, 0,
hWndParent, NULL, g_hInst, NULL);
if (hWndToolbar == NULL)
{
return NULL;
}
HIMAGELIST hImageList = ImageList_Create(
GetSystemMetrics(SM_CXICON),
GetSystemMetrics(SM_CXICON),
ILC_MASK,
1, 1);
for(int index = 0; index < 3; index++)
{
HICON hIconItem = LoadIcon (g_hInst, MAKEINTRESOURCE(IDI_TOOL1 + index));
ImageList_AddIcon(hImageList, hIconItem);
DestroyIcon(hIconItem);
}
SendMessage(hWndToolbar, TB_SETIMAGELIST,0,(LPARAM)hImageList);
TBBUTTON tbButtons[3] =
{
{ 0, IDM_NEW, TBSTATE_ENABLED,TBSTYLE_BUTTON,{0}, 0, (INT_PTR)L"New" },
{ 1, IDM_OPEN, TBSTATE_ENABLED,TBSTYLE_BUTTON,{0}, 0, (INT_PTR)L"Open"},
{ 2, IDM_SAVE, TBSTATE_ENABLED,TBSTYLE_BUTTON,{0}, 0, (INT_PTR)L"Save"}
};
SendMessage(hWndToolbar, TB_BUTTONSTRUCTSIZE,(WPARAM)sizeof(TBBUTTON), 0);
SendMessage(hWndToolbar, TB_ADDBUTTONS,(WPARAM)3,(LPARAM)&tbButtons);
ShowWindow(hWndParent,SW_SHOW);
return hWndToolbar;
}