DOCUMENT:Q151901 06-MAY-2001 [visualc] TITLE :PRB: StatusBar Pane Enabled by Default PRODUCT :Microsoft C Compiler PROD/VER:winnt: OPER/SYS: KEYWORDS:kbMFC KbUIDesign kbVC400 kbVC410 kbGrpDSMFCATL kbMFCCtrlBar ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - The Microsoft Foundation Classes (MFC), used with: - Microsoft Visual C++ 32-bit Edition, versions 4.0, 4.1 ------------------------------------------------------------------------------- SYMPTOMS ======== When a non-default pane is added to the StatusBar, this pane is automatically enabled even if it does not have an Update UI handler. CAUSE ===== This behavior is different than the behavior in earlier versions of MFC where the pane was automatically disabled if there was no Update UI handler. RESOLUTION ========== To disable the pane, unless it is enabled by a handler, add an Update UI handler for the pane to the CMainFrame class of the application that disables the pane. STATUS ====== This behavior is by design. MORE INFORMATION ================ In certain situations the pane can be disabled by default, such as when the pane is displaying the status associated with a Document or the View. In these situations, you should disable the pane if no Document/View is open. To disable the pane by default, add an Update UI handler for this pane to CMainFrame. Add an update UI handler in the Document or View that updates the pane depending on the status. When a Document/View is open, then the update UI handler in the Document/View will update the pane depending on its state. When all documents are closed, the Update handler in CMainFrame will disable the pane. Sample Code ----------- /* Compile options needed: default */ // Following code disables a pane in the StatusBar with ID, // ID_MYPANE in the CMainFrameClass. // MainFrm.h : interface of the CMainFrame class ... class CMainFrame : public CMDIFrameWnd { ... //}}AFX_MSG afx_msg void OnUpdateMypane(CCmdUI* pCmdUI); DECLARE_MESSAGE_MAP() }; // MainFrm.cpp : implementation of the CMainFrame class ... BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) //{{AFX_MSG_MAP(CMainFrame) ... //}}AFX_MSG_MAP ON_UPDATE_COMMAND_UI(ID_MYPANE, OnUpdateMypane) END_MESSAGE_MAP() static UINT indicators[] = { ID_SEPARATOR, // status line indicator ID_MYPANE, //String resource with this ID in resources ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_SCRL, }; ... void CMainFrame::OnUpdateMypane(CCmdUI* pCmdUI) { pCmdUI->Enable(FALSE); } Additional query words: 4.00 4.10 CStatusBar enable ====================================================================== Keywords : kbMFC KbUIDesign kbVC400 kbVC410 kbGrpDSMFCATL kbMFCCtrlBar Technology : kbAudDeveloper kbMFC Version : winnt: Issue type : kbprb ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 2001.