Print Page | Close Window

Remove Control on Menu (2 levels deep)

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=3050
Printed Date: 13 July 2025 at 1:38pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Remove Control on Menu (2 levels deep)
Posted By: thodgson
Subject: Remove Control on Menu (2 levels deep)
Date Posted: 17 October 2005 at 1:11pm

The following code will remove a command that is just below a top level menu, e.g. File -> Open, however if you try and remove one level below that, an ASSERT is thrown.

How do I remove a menu item (control) that is 2 levels down, e.g. File -> Open -> Something?

 

Does not work for all controls...

OnInitCommandsPopup(CXTPCommandBar* pCommandBar)
{
   CXTPControl* pCommandSubItem = pCommandList->FindControl(xtpControlButton, ID_TOOLS_SUBITEM, TRUE, TRUE);
   if (pCommandSubItem)
   {
       pCommandList->Remove(pCommandSubItem);
   }
}



-------------
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



Replies:
Posted By: thodgson
Date Posted: 17 October 2005 at 1:15pm

FYI: the parameter "visible" in the call to FindControl must be set to FALSE

CXTPControl* pCommandSubItem = pCommandList->FindControl(xtpControlButton, ID_TOOLS_SUBITEM, TRUE, FALSE);



-------------
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


Posted By: Oleg
Date Posted: 17 October 2005 at 3:00pm

instead

pCommandList->Remove(pCommandSubItem);

use

pCommandSubItem->GetControls()->Remove(pCommandSubItem);



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: thodgson
Date Posted: 19 October 2005 at 7:08pm

Okay, that seems odd to use the object to remove itself, but...you guys wrote it and it works.

 



-------------
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


Posted By: mailhaim
Date Posted: 17 January 2006 at 10:10am

I need to remove sub menu item too but the above suggestion does not work( pCommandSubItem->GetControls()->Remove(pCommandSubItem); )

An example: I have sub menu with 3 items: A, B & C. I try to remove C. When I open the menu I get A, B, B.

Any ideas?




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