如何更改 CMFCToolBar 运行时 [英] How to change CMFCToolBar runtime
本文介绍了如何更改 CMFCToolBar 运行时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在某些条件下使用相同的 CMFCToolBar 对象(它是 CMainFrame 的成员)在我的 SDI 应用程序中切换工具栏.我正在尝试这样做:
I need under certain conditions to switch toolbars in my SDI application using the same CMFCToolBar object, which is the member of CMainFrame. I'm trying to do it like this:
void CMainFrame::ChangeTlbr(const int tlbIdx)
{
m_wndToolBar.ResetImages();
switch (tlbIdx)
{
case 0 :
m_wndToolBar.LoadToolBar(IDR_TLBR1);
break;
case 1:
m_wndToolBar.LoadToolBar(IDR_TLBR2);
break;
}
m_wndToolBar.Invalidate();
m_wndToolBar.UpdateWindow();
}
但是没有加载下一个工具栏的位图.
But bitmap of the next toolbar is not loaded.
在这种情况下我做错了什么,是否有更好的方法来做到这一点?
What am i doing wrong in this case, and if there is better way to do this?
推荐答案
以下函数展示了如何将当前工具栏替换为另一个定义为 IDR_MAINFRAME1 的工具栏:
The following function shows how to replace the current toolbar by another one, defined as IDR_MAINFRAME1:
void CMainFrame::OnChangeToolbar()
{
m_wndToolBar.ResetAllImages();
m_wndToolBar.LoadToolBar(IDR_MAINFRAME1);
m_wndToolBar.LoadBitmap(IDR_MAINFRAME1);
m_wndToolBar.AdjustSizeImmediate();
}
这篇关于如何更改 CMFCToolBar 运行时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文