Using 256 color bitmaps in toolbar

This tip was contributed by Kevin Bentley.
He has tried this on a 256 color display as well.

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:


Here is the fix, just replace the load bitmap call with a call to the control itself:


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!

More by Author

Must Read