我想讓我的工具欄與ImageList
一起工作。這些圖像是單獨的PNG,因此我將它們連續添加到ImageList
中,但Bbt不起作用。下面是代碼的Image
添加到ImageList
:試圖用ImageList創建一個工具欄,不工作
HIMAGELIST CreateToolBarImages(HINSTANCE hInst)
{
HIMAGELIST v_ImageList = NULL;
// IMAGE_LIST v_Img;
HICON hIcon;
HBITMAP hBit;
COLORMAP cMap;
COLORREF fromColor = RGB(0,0,0);
InitCommonControls();
v_ImageList = ImageList_Create(32, 32, ILC_MASK, 1, 1);
cMap.from = fromColor;
cMap.to = ::GetSysColor(COLOR_BTNFACE);
hBit = CreateMappedBitmap(hInst, IDB_CONSOLE, 0, &cMap, 1);
// hBit = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_CONSOLE));
consoleImg = ImageList_Add(v_ImageList, hBit, 0);
if (consoleImg == -1)
return NULL;
DeleteObject(hBit);
// [edit Franci Penov]
return v_ImageList;
}
然後,我創建工具欄,但它在圖像功能失效。
HWND CreateToolBarButton(HWND hWndParent)
{
const int ImageID = 0;
const int numB = 1;
COLORREF iColor;
HWND hToolBar = CreateWindowEx(0,
TOOLBARCLASSNAME,
NULL,
WS_CHILD |TBSTYLE_LIST |TBSTYLE_FLAT | WS_VISIBLE,
0,0,0,0,
hWndParent,
NULL,
g_hInst,
NULL);
if (hToolBar == NULL)
return NULL;
HIMAGELIST ImgList = CreateToolBarImages(g_hInst);
if (ImgList == NULL)
MessageBox(hWndParent, L"No Tool Images", L"BOB", MB_OK);
// [edit Franci Penov]
return hToolBar;
}
有什麼我失蹤或沒有做?