|
|
|
|
Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
Lars Fischer
|
Sep 20, 2005 - 10:49 AM
|
Hi,
i’d like to change the menu title at runtime. you provided a sample for changing menu items with given id’s but the titles of the menu don’t have a ID. How can I do this on a dialog-base application?
Lars
|
|
Technical Support
|
Sep 20, 2005 - 1:20 PM
|
We may guess you want to change text of some menu bar item on-the-fly. The menu bar is controlled by the CExtMenuControlBar class, which is derived from the CExtToolControlBar class. So, the "menu title" in your question is a set of CExtBarButton objects which are created inside the menu bar. In other words, they "fake" the menu line. In fact, these buttons have their command identifiers which are allocated/freed by the command manager on-the-fly. So, just access these buttons and invoke their GetCmdID(true) method that returns an identifier of the button. After that, call the g_CmdManager->CmdGetPtr() method (specify the button’s identifier as the second argument) and get the CExtCmdItem object which has the m_sToolBarText property, which is exactly you need. So, just modify it and invoke the CWnd::RepositionBars() method of the menu bar’s parent dialog window. There is one more option: you can invoke the UpdateMenuBar() method of the menu bar. As a result, it will call the CExtMenuControlBar::_UpdateMenuBar() internal virtual method. The latter creates menu bar’s buttons. So, create and use a CExtMenuControlBar -derived class and override the CExtMenuControlBar::_UpdateMenuBar() internal virtual method. In this method, you can assign custom text to menu bar’s buttons.
|
|