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:
C++
//CMFCToolBar       m_wndToolBar;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!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));
	//m_wndToolBar.LoadBitmap(MakeBitMapTransparent(hBitmap));
	//m_wndToolBar.CleanUpImages();


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] http://stackoverflow.com/questions/9306980/cmfcmenubar-kind-of-transparency-for-a-cmfctoolbar?rq=1[^]
Thanks
Posted
Updated 7-Sep-18 0:45am
v2

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
 
Comments
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    
http://social.msdn.microsoft.com/Forums/en-US/vcmfcatl/thread/897e71e0-b644-4f60-945c-2fe6aa137136/
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.CleanUpLockedImages();
m_wndToolBar.LoadBitmap(IDR_MAINFRAME_2, 0, 0, TRUE /* Locked */);
AdjustLayout();
 
Share this answer
 
v7

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