Hi,
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
Loading Bmp from toolbar in MFC
Quote: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:
toolbar->GetBitmap(ID_FILE_CLOSE)
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]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement