Jump to content
  • Advertisement
Sign in to follow this  

Loading Bmp from toolbar in MFC

This topic is 3093 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


I am trying to load bitmap from toolbar using MFC. I have a toolbar object m_pToolbar. The toolbar contains many buttons with bitmap. I am doing as follows

CBitmap bm;
int bmpIdx = m_pToolbar->GetBitmap(ID_XYZ);
BOOL b = bm.LoadBitmap(bmpIdx);

when debugging i get an index value of the bitmap in toolbar in bmpIdx variable. However when I try to load the bmp using this index, the function returns 0 i.e. the bitmap is not loaded. I don't know why does this not work. Has anyone any idea how to accomplish this task. Thanks

Best regards

Share this post

Link to post
Share on other sites
i get an index value of the bitmap in toolbar

That's not quite correct. toolbar->GetBitmap(commandID) returns an index position (not a bitmap resource id for the button) in the toolbar for the button that, when clicked, responds to the commandID.

That return value is not the identifier for a bitmap resource, which is what CBitmap->LoadBitmap(resourceID) requires.

For instance, if you have buttons in order from left-to-right for ID_FILE_OPEN, ID_FILE_CLOSE and ID_FILE_LOAD:


returns the value 1, the zero-based index for the button which responds to the menu command ID_FILE_CLOSE.

EDIT: I'm personally not aware of functions which support retrieving an individual bitmap from an MFC Toolbar resource.

[Edited by - Buckeye on July 1, 2010 2:58:36 PM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!