CMFCToolbar:使用自定义位图(HBITMAP)运行时 [英] CMFCToolbar: use Customized bitmap(HBITMAP ) runtime

查看:110
本文介绍了CMFCToolbar:使用自定义位图(HBITMAP)运行时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

//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();





我创建了一个MDC MDI应用程序,其中有一个使用位图的TOOLBAR;



我想运行时更新BITMAP并再次想把它加载到工具栏;但我无法找到办法去做;在上面的代码中,IDR_MAINFRAME_256是带有图像的工具栏;要创建这个项目,只需在VS中创建一个MDI应用程序;



任何想法如何运行时间使用位图的HBITMAP更新位图?

[同样的问题] http://stackoverflow.com/问题/ 9306980 / cmfcmenubar-kind-of-transparent-for-a-cmfctoolbar?rq = 1 [ ^ ]

谢谢



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

推荐答案

使用需要使用不同的工具栏和实际的位图。您是否可以创建一个新的并删除旧的,或创建一个数组。
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.


进入代码,您将看到位图附加到工具栏,所以你不能改变它。所以你需要另一个工具栏。



我在旧版XP中完成了它并且工作正常。
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.


可能是一个有点晚了,但它可能会帮助别人。

不,不需要另一个工具栏。



创建工具栏时,位图会加载到CMFCToolBar内部对象,可以通过CleanUpLockedImages重置。在此之后,可以通过调用LoadBitmap加载另一个位图(与创建期间相同)。 AdjustLayout然后进行重新绘制工作。



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();


这篇关于CMFCToolbar:使用自定义位图(HBITMAP)运行时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆