Click here to Skip to main content
15,879,613 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
//CMFCToolBar       m_wndToolBar;
		!m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME))
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	HBITMAP hBitmap = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BITMAP1));

I have created one MDC MDI app which has one TOOLBAR which is using a bitmap;

I want to run time update that BITMAP and again want to load it to the Toolbar; But I am not able to find way to do it; IN above code, IDR_MAINFRAME_256 is a Toolbar with image; To create this project, just create a MDI application in VS;

Any Idea how can I run time update the Bitmap using bitmap's HBITMAP?
[Same problem as][^]
Updated 7-Sep-18 0:45am

use need to use DIFFERENT toolbars with the actual bitmap. Whether you create a new one and delete the old, or create an array is your choice.
Share this answer
iDebD 13-May-13 10:44am    
What I checked if I can use a PNG image in place of BMP, in that case case the background can be transparent (As BMP can't have transparent information?);

But not sure if I can use a PNG image in CMFCToolbar button
iDebD 13-May-13 11:07am
KarstenK 14-May-13 3:27am    
Fine - if its works ;-)
step into the code and you will see, that the bitmap is attached to the toolbar, so you cant change it. So you need another toolbar.

I have done that in the old XP-times and it worked fine.
Share this answer
Probably a little bit late, but it might help others.
No, there's no need for another toolbar.

When creating a toolbar the bitmap is loaded to a CMFCToolBar internal object, which can be reset by CleanUpLockedImages. After this another bitmap can be loaded with a call to LoadBitmap (same as during creating). AdjustLayout then does the re-paint job.

m_wndToolBar.LoadBitmap(IDR_MAINFRAME_2, 0, 0, TRUE /* Locked */);
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900