Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to change CMFCToolBar toolbar images?

659 views
Skip to first unread message

JiiPee

unread,
Nov 26, 2016, 6:38:30 AM11/26/16
to
How to change CMFCToolBar s button image using a bitmap from the resource?

Such a simple task and I can to it with CToolbar, but the documentation
is poor and have been googling many hours and found nothing.

My current code, which does not work:

h-file:
CMFCToolBar m_toolBar;
CMFCToolBarImages m_mfcToolBarImages;
CMFCToolBarButton but;

--------------------------------
cpp-file:

CBitmap bm;
HBITMAP hBitmap = (HBITMAP) ::LoadImage(AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDB_BITMAP1), IMAGE_BITMAP,
0, 0, LR_CREATEDIBSECTION | LR_LOADMAP3DCOLORS);

m_mfcToolBarImages.AddImage(hBitmap);
CMFCToolBar::SetUserImages(&m_mfcToolBarImages);

but.SetImage(0);
m_toolBar.InsertButton(but);
-----------------------------------------------------------------
SetUserImages returns true so I am supposing it was succesfull. But how
do I now link m_mfcToolBarImages with buttons so that toolbar uses those
images. Even creating a new button (InsertButton) uses the default
toolbar images so not the ones from m_mfcToolBarImages.

Thanks
0 new messages