I'm migrating a legacy GUI application to VS2012. When running this application in debug mode, I'm getting a debug assertion when I try to instantiate a toolbar with the following line of code:
if(!m_wndMain.Create(this) || !m_wndMain.LoadToolBar(IDR_MAIN))
After digging around in MFC code, I found that the following line has changed in bartool.cpp has changed in MSVC10->11 from:
if (lpBitmap == NULL)
to:
if ((lpBitmap == NULL) || (lpBitmap->biBitCount > 8))
in AfxLoadSysColorBitmap.
In my case lpBitmap->biBitCount = 24 which causes AfxLoadSysColorBitmap to return NULL which in turn causes the debug assertion.
Any ideas on how to rectify my program's behavior to avoid this debug assertion?
Apart from changing the bitmap to be 8-bit (256 colors) your best option is to use CMFCToolBar instead. This supports higher bit-depth bitmaps (including 24 and 32 bit) bitmaps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With