spin_eight
spin_eight

Reputation: 4025

Does CToolbar support buttons with 32 bit icons?

Problem:
Adding 32bit icons to a CToolbar instance seems not to work properly
(quality of image changes).

I encountered in the WEB 2 categories of topics, related to my issue:

it is strange that "16 colors" is mentioned in documentation, not 2^16 colors, so I might interpreted that information wrongly.

Upvotes: 1

Views: 974

Answers (3)

user1793036
user1793036

Reputation: 199

For quite some time CToolBar has supported images via image lists.

So the trick to load the default 16 colour image that is part of the toolbar resource and then to create image lists at any colour depth before assigning them to the toolbar via the contained CToolBarCtrl.

ie.

if (m_toolbar.LoadToolBar(IDR_MAINFRAME))
{
   // create imagelist
   if (m_imageList.Create(....))
   {
      m_toolbar.GetToolBarCtrl().SetImageList(&m_ilNormal);
   }
}

Upvotes: 1

snowdude
snowdude

Reputation: 3874

If you look at CToolBar::LoadBitmap you'll see that the bitmaps are loaded using AfxLoadSysColorBitmap. A quick look at that function shows that the color table is fixed at 16 colors.

// make copy of BITMAPINFOHEADER so we can modify the color table
const int nColorTableSize = 16;

As with most things in MFC you probably could make it load a 32-bit bitmap if you override enough methods but as you've probably been seeing elsewhere you really want to be using CMFCToolBar not just for the support for higher color depths but also many other improved features.

Upvotes: 2

KonstantinL
KonstantinL

Reputation: 667

Probably you should use CMFCToolBar: http://msdn.microsoft.com/ru-ru/library/bb984480.aspx

Upvotes: 0

Related Questions