Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - Trying to delete a popup menu
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Trying to delete a popup menu

 Post Reply Post Reply
Author
Message
MadRiver View Drop Down
Groupie
Groupie


Joined: 21 August 2008
Location: United States
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote MadRiver Quote  Post ReplyReply Direct Link To This Post Topic: Trying to delete a popup menu
    Posted: 27 October 2008 at 9:46am
Hello,

My application allows users to add and remove menu items via scripting. When all the menu items are removed from a particular menu, I would like to remove the menu.

Currently, I try to a find a menu item by ID, confirm that it is CommandBarButton, then delete it:
pControl->Delete();

Before deleting, I get the control's parent:
ICommandBar * pParent = pControl->GetParent();
// xtpBarTypePopup == pParent->GetType();
long cnt = pParent->GetControls()->GetCount();
if (0 == cnt) {
    pParent->Delete();
}
This call to Delete() crashes.
What am I doing wrong?
Thanks for any insight...

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: 27 October 2008 at 10:49am
Hi,
 
pParent is PopupBar of Control. You need Delete not PopupBar but Control that has this Popupbar as Child CommandBar. so Find it and remove.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
MadRiver View Drop Down
Groupie
Groupie


Joined: 21 August 2008
Location: United States
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote MadRiver Quote  Post ReplyReply Direct Link To This Post Posted: 29 October 2008 at 3:22pm
Thanks for the reply.
I am able to delete the menu if it is only one level deep, but I'm not sure I have the most efficient approach.
When I find the menuItem to remove, I get its parent, a CommandBarPopup control. Do I have to traverse all the controls in the top-level CommandBar, looking for the Control with the matching CommandBar?

I also need to handle hierarchical menus, and I am having trouble traveling up the hierarchy.


For example:
TopLevel
----Level1
--------Level2
------------MenuItem1

When I delete MenuItem1, I want to see if its 'parent' (Level2) is empty, and delete it if it is. Similarly, I want to get Level2's parent, and delete it if it is empty, and so on.
Is there a straightforward way to do this?   
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.203 seconds.