CMFCOutlookBarPane icons disappearing when dragging

徘徊边缘 提交于 2019-12-13 03:58:59

问题


In Visual C++, I have a CMFCOutlookBarTabCtrl that has been created with:

CMFCOutlookBarTabCtrl* pOutlookBar = (CMFCOutlookBarTabCtrl*) m_wndContextBar.GetUnderlyingWindow();

where wndContextBar is a CMyOutlookBar that is a class I derived from CMFCOutlookBar

I also have the 3 CMFCOutlookBarPanes I create within the if below:

DWORD dwPaneStyle = AFX_DEFAULT_TOOLBAR_STYLE | CBRS_FLOAT_MULTI;

// can float, can autohide, can resize, CAN NOT CLOSE
DWORD dwStyle = AFX_CBRS_FLOAT | AFX_CBRS_AUTOHIDE | AFX_CBRS_RESIZE | CBRS_GRIPPER;

if (!m_wndPane0.Create(&m_wndContextBar, dwPaneStyle, PANE0_ID, dwStyle) ||
    !m_wndPane1.Create(&m_wndContextBar, dwPaneStyle, PANE1_ID, dwStyle) ||
    !m_wndPane2.Create(&m_wndContextBar, dwPaneStyle, PANE2_ID, dwStyle))
    )
{
    ASSERT(FALSE);
    return FALSE;
}

And the code follows:

m_wndPane0.SetOwner(this);
m_wndPane1.SetOwner(this);
m_wndPane2.SetOwner(this);
m_wndPane0.EnableTextLabels();
m_wndPane1.EnableTextLabels();
m_wndPane2.EnableTextLabels();

m_wndPane0.EnableDocking(CBRS_ALIGN_ANY);
m_wndPane1.EnableDocking(CBRS_ALIGN_ANY);
m_wndPane2.EnableDocking(CBRS_ALIGN_ANY);

    [....]//Code for adding buttons inside the panes, it is irrelevant for this discussion

pOutlookBar->SetImageList(IDB_CONTEXT_ICONS, 32, RGB(255,255,255));

sTitle.LoadString(IDS_PANE0);
pOutlookBar->AddControl(&m_wndPane0, sTitle, 0, TRUE, dwStyle); 
m_wndPane0.EnableDocking(CBRS_ALIGN_ANY);
m_wndPane0.SetDefaultState();

sTitle.LoadString(IDS_PANE1);
pOutlookBar->AddControl(&m_wndPane1, sTitle, 1, TRUE, dwStyle); 
m_wndPane1.EnableDocking(CBRS_ALIGN_ANY);
m_wndPane1.SetDefaultState();

sTitle.LoadString(IDS_PANE2);
pOutlookBar->AddControl(&m_wndPane2, sTitle, 2, TRUE, dwStyle); 
m_wndPane2.EnableDocking(CBRS_ALIGN_ANY);
m_wndPane2.SetDefaultState();

m_wndContextBar.SetPaneStyle(m_wndContextBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
m_wndContextBar.FillDefaultTabsOrderArray();

pOutlookBar->EnableTabSwap(TRUE);

CMFCOutlookBarTabCtrl::EnableAnimation(TRUE);

UpdateMDITabbedBarsIcons();

I define that icons will be appearing on the panes with the SetImageList line above. When I create the Toolbar everything is OK. But when I try to drag one of the Panes to another position inside the Outlook bar, its icon disappears.

So, what is the solution for the image to be visible after dragging?

Side note: When dragging, the Pane passes temporarily to a state where it is undocked, where its title bar is shorter and has no icon, which does not seem incorrect to me. What is really irritating is when the Pane is redocked the returns to its original height as expexted, but the icon isn't shown.

Thanks in advance for help, Sérgio


回答1:


I ended doing

m_wndContextBar.SetMode2003();

before

m_wndContextBar.Create( ..... );

So, after doing that, the panels are not moveable outside, and the icon does not disappear. Not really a solution, but it works for now.




回答2:


Not really a solution again, but I've managed to have the panels "position-locked" without having the mode 2003:

CString sTitle;
sTitle.LoadString(IDS_CONTEXT);

//m_wndContextBar.SetMode2003();
if (!m_wndContextBar.Create(sTitle, this, CRect(0, 0, 150, 400), CONTEXT_TAB_ID, 
                            WS_CHILD|WS_VISIBLE|CBRS_LEFT/*|CBRS_GRIPPER*/, 
                            AFX_CBRS_RESIZE|AFX_CBRS_CLOSE|AFX_CBRS_AUTOHIDE/*|AFX_CBRS_FLOAT*/))
{
    ASSERT(FALSE);
    return FALSE;
}

CMFCOutlookBarTabCtrl* pOutlookBar = (CMFCOutlookBarTabCtrl*) m_wndContextBar.GetUnderlyingWindow();
if (!pOutlookBar)
{
    ASSERT(FALSE);
    return FALSE;
}

DWORD dwPaneStyle = AFX_DEFAULT_TOOLBAR_STYLE;
DWORD dwStyle = NULL;

if (!m_wndPane0.Create(&m_wndContextBar, dwPaneStyle, PANE0_ID, dwStyle) ||
    !m_wndPane1.Create(&m_wndContextBar, dwPaneStyle, PANE1_ID, dwStyle) ||
    !m_wndPane2.Create(&m_wndContextBar, dwPaneStyle, PANE2_ID, dwStyle))
{
    ASSERT(FALSE);
    return FALSE;
}

m_wndPane0.SetOwner(this);
m_wndPane1.SetOwner(this);
m_wndPane2.SetOwner(this);
m_wndPane0.EnableTextLabels();
m_wndPane1.EnableTextLabels();
m_wndPane2.EnableTextLabels();

m_wndPane0.EnableDocking(CBRS_ALIGN_TOP);
m_wndPane1.EnableDocking(CBRS_ALIGN_TOP);
m_wndPane2.EnableDocking(CBRS_ALIGN_TOP);

[....]//Code for adding buttons inside the panes, it is irrelevant for this discussion

pOutlookBar->SetImageList(IDB_CONTEXT_ICONS, 32, RGB(255,255,255));

sTitle.LoadString(IDS_PANE0);
pOutlookBar->AddControl(&m_wndPane0, sTitle, 0, TRUE, dwStyle); 
m_wndPane0.SetDefaultState();

sTitle.LoadString(IDS_PANE1);
pOutlookBar->AddControl(&m_wndPane1, sTitle, 1, TRUE, dwStyle); 
m_wndPane1.SetDefaultState();

sTitle.LoadString(IDS_PANE2);
pOutlookBar->AddControl(&m_wndPane2, sTitle, 2, TRUE, dwStyle); 
m_wndPane2.SetDefaultState();


m_wndContextBar.SetPaneStyle(m_wndContextBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
m_wndContextBar.FillDefaultTabsOrderArray();

pOutlookBar->EnableTabSwap(FALSE);
pOutlookBar->EnableTabDetach(0,FALSE);
pOutlookBar->EnableTabDetach(1,FALSE);
pOutlookBar->EnableTabDetach(2,FALSE);
//pOutlookBar->EnableTabDetach(3,FALSE);

CMFCOutlookBarTabCtrl::EnableAnimation(TRUE);

UpdateMDITabbedBarsIcons();


来源:https://stackoverflow.com/questions/6062088/cmfcoutlookbarpane-icons-disappearing-when-dragging

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!