Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug assertion in MFC in VS2012

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?

like image 761
eladidan Avatar asked May 28 '26 04:05

eladidan


1 Answers

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.

like image 99
snowdude Avatar answered May 30 '26 19:05

snowdude



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!