Microsoft KB Archive/151901

= PRB: StatusBar Pane Enabled by Default =

Article ID: 151901

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 4.0 Professional Edition

 Microsoft Visual C++ 4.1 Subscription

 Microsoft Visual C++ 5.0 Learning Edition 

-

<div class="notice_section">

This article was previously published under Q151901

<div class="symptoms_section">

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.

<div class="cause_section">

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.

<div class="resolution_section">

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.

<div class="status_section">

STATUS
This behavior is by design.

<div class="moreinformation_section">

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 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: kbmfcctrlbar kbprb kbuidesign KB151901

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.