PRB: Setting First Pane of CStatusBarLast reviewed: May 28, 1997Article ID: Q110505 |
The information in this article applies to:
SYMPTOMSIf the text in the first pane of a CStatusBar window is changed using SetPaneText() and a menu is selected, the text is overwritten by the Help prompts for the menu.
CAUSESetting any but the first pane of the status bar is relatively simple. You just need to set the pane using SetPaneText() and make sure you have added in an ON_UPDATE_COMMAND_UI handler for the ID of that pane (set in your MAINFRAME.CPP as an element of an indicators[] array). This handler should call Enable() in the following manner to make sure that the pane is not erased:
void CMainFrame::OnUpdateMystat(CCmdUI* pCmdUI) { pCmdUI->Enable(); }However, setting the FIRST pane of a status bar using SetPaneText() or calling SetWindowText() on the status bar is a bit more difficult. The problem is that the framework itself is changing the first pane using some special techniques. Basically, the framework is passing a WM_SETTEXT command directly to the status bar, from a number of places within its own code. Adding ON_UPDATE_COMMAND_UI handlers or calling SetPaneText() for the first pane of the status bar does not permanently set it. The framework eventually sends a WM_SETTEXT message directly to the status bar, changing the text from what was set.
RESOLUTIONOne way of setting the first pane yourself and keeping it set to what you want is to derive your own class from CStatusBar (for example CMyStat) and to give it a WM_SETTEXT handler. (Adding the WM_SETTEXT handler cannot be done using ClassWizard, so the handler must be added by hand.) The steps to do this are as follows:
You could also add member functions to your status bar class that both set the text of the status bar and set the bIgnoreSetText flag to lock or unlock the status bar in one step. You might call them SetPaneOneAndLock() and SetPaneOneAndUnlock(). |
Keywords : MfcUI kbprb
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |