May 6th, 2013, 07:46 AM
Dynamic icons on CMFCRibbonStatusBarPane
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:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
TRACE0("Failed to create status bar\n");
return -1; // fail to create
HICON icon = LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_ICON1));
DWORD error = GetLastError();
bNameValid = strTitlePane1.LoadString(IDS_STATUS_PANE2);
CMFCRibbonStatusBarPane* pane = new CMFCRibbonStatusBarPane(ID_STATUSBAR_PANE2, strTitlePane2, TRUE, icon);
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?
March 8th, 2014, 09:32 PM
Re: Dynamic icons on CMFCRibbonStatusBarPane
Add ON_COMMAND(ID_STATUSBAR_PANE2,&CMainFrame::OnStatusbarPane2) to enable your status bar icon which is disabled (gray).
Originally Posted by Cristi
Tags for this Thread
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!