Home Dashboard Directory Help

Issue with CMFCToolBarImages::AddImage with 32bit Images introduced in VS2010 by McNitt


 as Fixed Help for as Fixed

Sign in
to vote
Type: Bug
ID: 634898
Opened: 1/6/2011 8:42:11 AM
Access Restriction: Public
User(s) can reproduce this bug


The following code was added to
int CMFCToolBarImages::AddImage(const CMFCToolBarImages& imageList, int nIndex)
in Visual Studio 2010. The problem looks to be with accessing the ds.dsBmih structure since this strcture is all zero causing the biPlanes to be set to 0 causing the CreateDIBSection to fail.
I think they may have wanted to use the ds.dsBm which is correctly filled in.

    if (imageList.m_nBitsPerPixel >= 24 && ::GetObject(m_hbmImageWell, sizeof(DIBSECTION), &ds) != 0)
        BITMAPINFO bi = {0};
        bi.bmiHeader.biSize        = sizeof(BITMAPINFOHEADER);
        bi.bmiHeader.biWidth     = imageList.m_sizeImage.cx;
        bi.bmiHeader.biHeight     = imageList.m_sizeImage.cy;
        bi.bmiHeader.biPlanes     = ds.dsBmih.biPlanes;
        bi.bmiHeader.biBitCount    = ds.dsBmih.biBitCount;
        bi.bmiHeader.biCompression = BI_RGB;

        COLORREF* pBits = NULL;
        HBITMAP hNewBitmap = ::CreateDIBSection(dc, &bi, DIB_RGB_COLORS, (void **)&pBits, NULL, NULL);
        bitmap.Attach (hNewBitmap);
Sign in to post a comment.
Posted by McNitt on 1/17/2011 at 6:00 AM
I recieved the following answer to this problem.
"This issue has been fixed in MFC for the next major release of Visual Studio"
When is the next Major release. I assume this is not getting fixed in the SP 1 of Visual Studio 2010?
Posted by Microsoft on 1/14/2011 at 1:26 PM

Thanks for the report. This issue has been fixed in MFC for the next major release of Visual Studio.

Pat Brenner
Visual C++ Libraries Development
Posted by Microsoft on 1/10/2011 at 11:43 PM
Thanks for your feedback. We are routing this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by McNitt on 1/7/2011 at 4:20 AM
I added a zip file that demostrates the problem.
The only modification I made to a default MFC application project was to add the following lines to the end of CMainFrame::OnCreate

    CMFCRibbonCategory *pCategory(m_wndRibbonBar.AddContextCategory(_T("Test\nj"), _T("Test"), 1, AFX_CategoryColor_Red,
        IDB_WRITESMALL, IDB_WRITELARGE, CSize(16, 16), CSize(32, 32), NULL));

    CMFCToolBarImages imagesPalette;
    imagesPalette.SetImageSize( CSize(32,32) );
    imagesPalette.AddImage( pCategory->GetLargeImages(),0 );
    if( imagesPalette.AddImage( pCategory->GetLargeImages(), 1 ) == -1 )
        ASSERT( FALSE );
Posted by Microsoft on 1/6/2011 at 6:30 PM
Thanks for reporting this issue. In order to fix the issue, we must first reproduce the issue in our labs. We are unable to reproduce the issue with the steps you provided.

Please give us a demo project to demonstrate this issue so that we can conduct further research.

It would be greatly appreciated if you could provide us with that information as quickly as possible. If we do not hear back from you within 5 days, we will close this issue.

Thanks again for your efforts and we look forward to hearing from you.

Microsoft Visual Studio Connect Support Team
Posted by Microsoft on 1/6/2011 at 8:58 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
File Name Submitted By Submitted On File Size  
AddImage Problem.zip 1/7/2011 11.72 MB