Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Remove Control on Menu (2 levels deep)
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Remove Control on Menu (2 levels deep)

 Post Reply Post Reply
Author
Message
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 Topic: Remove Control on Menu (2 levels deep)
    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)
Product: Xtreme Toolkit v13.1
Platform: Vista(x64)-SP1
Language: Visual C++ 6.0
Currently: Satisfied w/ Toolkit
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: 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)
Product: Xtreme Toolkit v13.1
Platform: Vista(x64)-SP1
Language: Visual C++ 6.0
Currently: Satisfied w/ Toolkit
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 17 October 2005 at 3:00pm

instead

pCommandList->Remove(pCommandSubItem);

use

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

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
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: 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)
Product: Xtreme Toolkit v13.1
Platform: Vista(x64)-SP1
Language: Visual C++ 6.0
Currently: Satisfied w/ Toolkit
Back to Top
mailhaim View Drop Down
Newbie
Newbie


Joined: 28 September 2005
Status: Offline
Points: 26
Post Options Post Options   Thanks (0) Thanks(0)   Quote mailhaim Quote  Post ReplyReply Direct Link To This Post 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?

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.