Object: To show or hide the Status Bar programmatically.
The mainframe (MF) is created conventionally as CFrameWndEx class by Visual Studio 10 wizard as a Doc/View application.
The status bar (SB) is created from the OnCreate message of CFrameWndEx class.
***** CFrameWndEx.h *****
#define SB_STYLE WS_CHILD | CBRS_BOTTOM | CBRS_TOOLTIPS | CBRS_FLYBY | WS_VISIBLE
#define SB_STYLE_EX WS_EX_CLIENTEDGE
CMFCStatusBar* p_SBCls;
***** CFrameWndEx.cpp *****
p_SBCls = new CJBK_III_SB;
ASSERT(p_SBCls->CreateEx(this, SB_STYLE_EX, SB_STYLE, nID));
The SB is toggled in CFrameWndEx class by:
b_Flag = p_RegCls->m_bGetRegFlag(ID_REGKEY_Item_SB, KEY_READ);
if (b_Flag)
p_SBCls->ShowWindow(SW_SHOW);
else
p_SBCls->ShowWindow(SW_HIDE);
p_SBCls->Invalidate(TRUE);
p_SBCls->UpdateWindow();
where the toggle flag, b_Flag, is stored in the registry and set by a check box in the RibbonBar; it is retrieved by m_bGetRegFlag(…). The toggle code (above) is called when either the check box is checked (or unchecked) and after the Status Bar is created from the main frame class.
The above works and the SB toggles as shown or hidden as required. The problem comes about when the application is created, the b_Flag is retrieved as TRUE and one attempts to hide the Status Bar by checking the checkbox on the Ribbon Bar. p_SCBls->IsVisible() == FALSE but the Status Bar is still visible.
If I move the mouse over the frame of CFrameWndEx and left click, the SB disappears. More check box clicking does nothing. If the application opens with b_Flag == FALSE, everything works as required. I am not sure what is causing this, however I get the feeling that I have to get the main frame or the SB region to redraw to get CFrameWndEx to redraw and erase the Status Bar.
Any input would be appreciated.
Thanks,
Barry