Question

I have a CMFCToolBar-derived class and an insance thereof is the member of a CDockablePane-derived class.

I looked at the VisualStudioDemo sample to see how it's done and have this so far:

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;
}

The high-color image (24bit) is loaded but the magenta mask (R255 G0 B255) is visible. I don't see how I can tell the toolbar to recognize the mask.
Is this even possible?

Was it helpful?

Solution

I don't know if this works every time but I use RGB(192, 192, 192) as the mask color and it does get recognized.

(Seems like the CMFCToolBar control is prepared to use ::GetSysColor(COLOR_BTNFACE) as the transparent color...)

OTHER TIPS

I just found out that a workaround is to use 32bit images together with their alpha channel. I tried using a 32bit image earlier but didn't get it to work for some other reason and then figured 32bit images won't work.

If you want to use 32 bit images don't use CBitmap instead use ATL::CImage or CPNGImage object and load corresponding resource ID.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top