如何使一个CMFCToolBar识别图像口罩?
-
22-07-2019 - |
题
我有一个CMFCToolBar
派生的类和它们的insance是CDockablePane
派生的类的成员。
我看着VisualStudioDemo样品,看看它是如何做,有这个迄今为止:
int CMyPane::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
// Removed all "return -1 on error" code for better readability
CDockablePane::OnCreate(lpCreateStruct);
if(m_toolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_MY_TOOLBAR) &&
m_toolBar.LoadToolBar(IDR_MY_TOOLBAR, 0, 0, TRUE /* Is locked */))
{
if(theApp.m_bHiColorIcons) // Is true, i.e. following code is executed
{
m_toolBar.CleanUpLockedImages();
m_toolBar.LoadBitmap(IDB_MY_TOOLBAR_24, 0, 0, TRUE /*Locked*/);
}
m_toolBar.SetPaneStyle(m_toolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY);
m_toolBar.SetPaneStyle(m_toolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT));
m_toolBar.SetOwner(this);
// All commands will be routed via this control , not via the parent frame:
m_toolBar.SetRouteCommandsViaFrame(FALSE);
}
return 0;
}
高的彩色图像(24位)加载,但品红掩模(R255 G0 B255)是可见的。我不明白我怎么能告诉工具栏承认面具。结果 这甚至可能?
解决方案
我不知道这是否正常工作,每次我却用RGB(192, 192, 192)
作为面膜的颜色,它并得到认可。
(好像CMFCToolBar控制准备使用::GetSysColor(COLOR_BTNFACE)
为透明色...)
其他提示
我刚发现一个解决方法是与他们的alpha通道一起使用的32位的图像。 我尝试使用较早的32位图像,但没有得到它的一些其他原因工作,后来想通32位图像将无法正常工作。
如果要使用的32倍的图像没有使用CBitmap
改用ATL::CImage
或CPNGImage object
并加载对应resource ID
。
不隶属于 StackOverflow