这就是我让它工作的方式:
First
正如其他人所说,在主工具栏旁边创建一个不可见的工具栏(我使用的是基于AppWizard名称的常用名称):
MainFrm.h:
class CMainFrame
{
//...
CMFCToolBar m_wndToolBar;
CMFCToolBar m_wndInvisibleToolBar;
//...
};
MainFrm.cpp:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
//...
// Normal, visible toolbar
if(m_wndToolBar.Create(this,
TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC))
{
VERIFY( m_wndToolBar.LoadToolBar(
theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME) );
// Only the docking makes the toolbar visible
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_wndToolBar);
}
// Invisible toolbar; simply calling Create(this) seems to be enough
if(m_wndInvisibleToolBar.Create(this))
{
// Just load, no docking and stuff
VERIFY( m_wndInvisibleToolBar.LoadToolBar(IDR_OTHERTOOLBAR) );
}
}
Second: The images and toolbar resources
IDR_MAINFRAME
and IDR_MAINFRAME_256
were generated by AppWizard. The former is the ugly 16 color version and the latter is the interesting high color version.
Despite its name, if I remember correctly, even the AppWizard-generated image has 24bit color depth. The cool thing: Just replace it with a 32bit image and that ll work, too.
有一个不可见的工具栏IDR_OTHERTOOLBAR
:我用资源编辑器创建了一个工具栏。只是一些伪图标和命令ID。VS随后生成了一个位图,我用我的高颜色版本替换了它。完成!
Note
Don t open the toolbars with the resource editor: It may have to convert it to 4bit before it can do anything with it. And even if you let it do that (because, behind Visual Studio s back, wou re going to replace the result with the high color image again, ha!), I found that it (sometimes?) simply cannot edit the toolbar. Very strange.
In that case I advise to directly edit the .rc file.