Professional UI Solutions
Site Map   /  Register
 
 

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.

Forums » Prof-UIS General Discussion » CExtCmdItem ponter Collapse All
Subject Author Date
Artur Shingirei Feb 23, 2004 - 2:50 AM

Hi. Thank`s for your fast replay.
Is exist another way to get the pCmdItem pointer?
if I has no ID for menu Item. (Top Level menu) I know only the position of the button.

Sergiy Lavrynenko Feb 28, 2004 - 1:25 PM

Hi,


If you know a position of a button in a menu bar (or in a toolbar), you can get a pointer to this button object, its ID and the CExtCmdItem object associated with it:

CExtBarButton * pTBB = m_wndMenuBar.GetButton( nPos );
UINT nCmdID = pTBB->GetCmdID( false );
CExtCmdItem * pCmdItem =  
   g_CmdManager->CmdGetPtr(
      g_CmdManager -> ProfileNameFromHwnd(
         m_wndMenuBar.m_hWnd
         ),
      nCmdID
      );

To change the text in a menu (or toolbar) for pCmdItem and recalculate the menu bar’s layout, the following code may be used:
pCmdItem -> m_sMenuText
      = pCmdItem -> m_sToolbarText
      = _T("text");
m_wndMenuBar.GetParentFrame() -> RecalcLayout();

Please note, the menu bar dynamically allocates and frees both command identifiers and CExtCmdItem objects each time when a new MDI child window is activated.