Hello everyone,
The goal is to change the status bar (CMFCRibbonStatusBar) icons based on some events.
(The old CMFCStatusBar class had the SetPaneIcon() member that easily solves the problem.)
The "improved" CMFCRibbonStatusBarPane has no members to set the icon, other then the constructor. Being a subclass of CMFCRibbonButton, it has SetImageIndex() that sets the icon index in the image list. The MS online help does not mention how and where to set that "list of images". My understanding is that the list belongs to the Button's parent; in this case it is the CMFCRibbonStatusBar, which has no methods to set any image list.
Can anyone please explain shortly how and where am I supposed to set that list of images for the status bar? Or another way to solve the problem?
Second related question:
I have tried to set the pane icon with the CMFCRibbonStatusBarPane() constructor by loading it from an icon resource. The icon appears shortly and then it is replaced by a gray patch. (for tests I also used one of the icons given by the MFC wizard, with the same result)
The code is:
Code:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
..........
if (!m_wndStatusBar.Create(this))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
HICON icon = LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_ICON1));
DWORD error = GetLastError();
TRACE1("%i\n", error);
ASSERT(icon);
CString strTitlePane2;
bNameValid = strTitlePane1.LoadString(IDS_STATUS_PANE2);
ASSERT(bNameValid);
CMFCRibbonStatusBarPane* pane = new CMFCRibbonStatusBarPane(ID_STATUSBAR_PANE2, strTitlePane2, TRUE, icon);
m_wndStatusBar.AddExtendedElement(pane, strTitlePane2);
..............
}
This code was placed within a program created by the MFC wizard that does nothing else.
I absolutely do not "touch" the status bar after it is created here in CMainFrame::OnCreate().
Apparently the icon is "erased" after OnCreate() exits. Where, how?
I have made HICON icon; a member of my CMainFrame class, with the same result.
Can anyone please suggest where to look for a solution to this problem?
Thank you.
Cris.