|
From: vitamin <vit...@nc...> - 2003-04-18 18:24:46
|
If you want to show your bitmaps in your toolbar button
NOT use CreateToolbarEx() function
and NOT use SendMessage(hToolbar,TB_ADDBITMAP,(WPARAM)3,(LPARAM)&tbab);
ONLY standard toolbar buttons can normal execute.
I tried many times, and got no error, no warning, and only close
application.
I think that the commctrl.a maybe is old.
Only imagelist can run.
And need to add #define TB_SETIMAGELIST (WM_USER + 48) in your commctrl.h
void ToolBar::CreateToolBar(void)
{
_tbhwnd=CreateWindowEx(WS_EX_DLGMODALFRAME,TOOLBARCLASSNAME,NULL,
WS_CHILD|WS_VISIBLE|TBSTYLE_FLAT|CCS_ADJUSTABLE|CCS_NODIVIDER,
0,0,0,0,_hwnd,NULL,_hwnd.GetInstance(),NULL);
HIMAGELIST hImage;
HBITMAP hBitImage;
hBitImage = LoadBitmap(_hwnd.GetInstance(), MAKEINTRESOURCE(IDTB_BMP));
hImage = ImageList_Create(16, 16, ILC_COLOR32| ILC_MASK , 12, 1);
ImageList_AddMasked(hImage, hBitImage, RGB(255, 255, 255));
SendMessage(_tbhwnd, TB_SETIMAGELIST, (WPARAM)0, (WPARAM)hImage);
DeleteObject(hBitImage);
}
void ToolBar::InitToolBar(void)
{
tool_bar_buttons[0].iBitmap=0;
tool_bar_buttons[0].idCommand=CM_FILE_NEW;
tool_bar_buttons[0].fsState=TBSTATE_ENABLED;
tool_bar_buttons[0].fsStyle=TBSTYLE_BUTTON;
tool_bar_buttons[0].dwData =0;
tool_bar_buttons[0].iString=0;
tool_bar_buttons[1].iBitmap=1;
tool_bar_buttons[1].idCommand=CM_FILE_LOAD;
tool_bar_buttons[1].fsState=TBSTATE_ENABLED;
tool_bar_buttons[1].fsStyle=TBSTYLE_BUTTON;
tool_bar_buttons[1].dwData =0;
tool_bar_buttons[1].iString=0;
// and others
SendMessage(_tbhwnd,TB_ADDBUTTONS,17,(LPARAM)(LPTBBUTTON)&tool_bar_buttons);
}
|