1

我有一个CMFCToolBar- 派生类,其实例是 -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)。我不知道如何告诉工具栏识别面具。
这甚至可能吗?

4

3 回答 3

3

我不知道这是否每次都有效,但我RGB(192, 192, 192)用作遮罩颜色并且它确实被识别。

(似乎 CMFCToolBar 控件已准备好::GetSysColor(COLOR_BTNFACE)用作透明颜色...)

于 2009-05-14T18:05:52.253 回答
0

我刚刚发现一种解决方法是使用 32 位图像及其 alpha 通道。我之前尝试使用 32 位图像,但由于其他原因无法正常工作,然后发现 32 位图像无法正常工作。

于 2009-05-08T10:59:44.383 回答
0

如果要使用 32 位图像,请不要CBitmap使用ATL::CImageorCPNGImage object并加载相应resource ID的 .

于 2012-03-21T15:00:43.907 回答