Using 256 color bitmaps in toolbar
Posted
by Kevin Bentley
on August 22nd, 1998
I recently needed to have 256 color toolbars in my app. If you create 256 color bitmaps in devstudio, and try to use them with CToolbar it won't work.
The problem is in the LoadBitmap() member or CToolbar. Appwizard will create the following line in your CMainFrame class:
m_wndToolBar.LoadBitmap(IDR_MAINFRAME)
Here is the fix, just replace the load bitmap call with a call to the control itself:
m_wndToolBar.GetToolBarCtrl().AddBitmap(iNumButtons,IDR_MAINFRAME);
It really is that easy, I found this solution after writing my own toolbar class that used the tool control directly, and 256 color bitmaps worked fine. I couldn't believe it, but it works!

Comments
Change bitmaps in toolbar in time of running
Posted by Legacy on 11/04/2003 12:00amOriginally posted by: Elina Lazebnik
I need change bitmaps for my toolbar (in FormView).
I can insert more from one bitmap to CToolBarCtrl by using CToolBarCtrl::AddBitmap() func. But I don't now how to change it in time of running.
Thanks
ReplyHow to put a .ico file on the toolbar button
Posted by Legacy on 09/11/2003 12:00amOriginally posted by: Gaurav Gumber
Hi,
The article is superb. But the problem with me is that I have a number of ".ico" files, each containing an icon. Kindly tell me how to put that on a toolbar button.
Regards
ReplyGaurav
finish method
Posted by Legacy on 08/12/2002 12:00amOriginally posted by: storein
It can load 256 Colors bitmap ,and you can dispose bitmap backgroud ,RGB (192,192,192 ) is Color Mask .and bitmap backgroud is RGB (192,192,192)
CImageList *pImgList = m_wndToolBar.GetToolBarCtrl().GetImageList();
pImgList->DeleteImageList();
pImgList->Create(48, 48, ILC_COLOR8 | ILC_MASK, 0, 10);
CBitmap ToolBarBm;
ReplyToolBarBm.LoadBitmap (IDB_ToolBar);
pImgList->Add (&ToolBarBm,RGB(192,192,192));
CBitmap DisToolBarBm;
DisToolBarBm.LoadBitmap (IDB_DisaToolBar);
CImageList* pDisaImgList;
pDisaImgList=new CImageList ;
pDisaImgList->Create(48, 48, ILC_COLOR8 | ILC_MASK, 0, 10);
pDisaImgList->Add (&DisToolBarBm,RGB(192,192,192));
m_wndToolBar.GetToolBarCtrl().SetImageList(pImgList);
m_wndToolBar.GetToolBarCtrl().SetDisabledImageList (pDisaImgList);
How to Highlight the button on toolbar ?
Posted by Legacy on 03/25/2002 12:00amOriginally posted by: anuradha
Reply256 color toolbar with disabled buttons.
Posted by Legacy on 01/21/2002 12:00amOriginally posted by: Rai, Fumihiko
ReplyAs usual... it doesnt work
Posted by Legacy on 11/01/2001 12:00amOriginally posted by: John
When i try this example, the program either fails to run or crashes.
Reply
Bitmaps go black when changing color depth
Posted by Legacy on 09/06/2001 12:00amOriginally posted by: Dan
If you change from 32 bit -> 16 bit color (actually between any two color depths), the bitmaps go black. Does anyone know of a solution for this or is it a bug in the toolbar control?
ReplyHow can i change the background color of ToolBar
Posted by Legacy on 05/30/2001 12:00amOriginally posted by: fhlove
I just want to change the background color of ToolBar.
ReplyHow can i do that??
Error in ~CToolBar()
Posted by Legacy on 11/22/2000 12:00amOriginally posted by: serrand
ReplyWorks Great!!
Posted by Legacy on 02/16/2000 12:00amOriginally posted by: Raghav Gupta
Works great! Thanks a lot!
ReplyLoading, Please Wait ...