Print Page | Close Window

Remove menu item at runtime

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=2445
Printed Date: 08 November 2025 at 11:32am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Remove menu item at runtime
Posted By: XIII
Subject: Remove menu item at runtime
Date 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



Replies:
Posted By: larryp
Date 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


Posted By: thodgson
Date 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 - http://www.ExclamationSoft.com )
Product: Xtreme Toolkit v13.1
Platform: Vista(x64)-SP1
Language: Visual C++ 6.0
Currently: Satisfied w/ Toolkit



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net