Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Remove menu item at runtime
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Remove menu item at runtime

 Post Reply Post Reply
Author
Message
XIII View Drop Down
Newbie
Newbie


Joined: 15 June 2005
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote XIII Quote  Post ReplyReply Direct Link To This Post Topic: Remove menu item at runtime
    Posted: 24 June 2005 at 3:26am
Hello,
I'm using XToolKit Pro and I don't know how to remove menu item at runtime ?

Before Xtoolkit i did it like this :
    ((CMainFrame *)m_pMainWnd)->GetMenu()->RemoveMenu(ID_FILE_PRINT, MF_BYCOMMAND);
    pCmdUI->Enable(FALSE);

Can anybody help me ?

Thanks
Back to Top
larryp View Drop Down
Groupie
Groupie


Joined: 15 January 2005
Location: United States
Status: Offline
Points: 61
Post Options Post Options   Thanks (0) Thanks(0)   Quote larryp Quote  Post ReplyReply Direct Link To This Post Posted: 24 June 2005 at 4:18pm
Try the following:

    CXTPControls* pControls = NULL;

    CXTPCommandBars* pCommandBars = GetCommandBars();
    if ( pCommandBars != NULL ) {
        CXTPMenuBar* pMenuBar = pCommandBars->GetMenuBar();
        if ( pMenuBar != NULL ) {
            pControls = pMenuBar->GetControls();
        }
    }
    if ( pControls != NULL ) {

        // Hide the button from the menu
        CXTPControl* pControl = pControls->FindControl(xtpControlButton, ID_FILE_LOGOFF, FALSE, TRUE);
        if ( pControl != NULL )  {
            pControl->SetVisible (FALSE);
        }
  }

Larry
Back to Top
thodgson View Drop Down
Groupie
Groupie


Joined: 11 August 2003
Status: Offline
Points: 78
Post Options Post Options   Thanks (0) Thanks(0)   Quote thodgson Quote  Post ReplyReply Direct Link To This Post Posted: 24 June 2005 at 8:23pm

To remove items, this is what we use:

CXTPControl* pCommandMenuItem = pCommandList->FindControl(xtpControlButton, ID_MENU_ITEM, TRUE, FALSE);
if (pCommandMenuItem)
{
     pCommandMenuItem->Remove(pCommandStopService);
}

Tim H(http://www.ExclamationSoft.com)
Product: Xtreme Toolkit v13.1
Platform: Vista(x64)-SP1
Language: Visual C++ 6.0
Currently: Satisfied w/ Toolkit
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.047 seconds.