![]()  | 
 
Trying to delete a popup menu | 
 
    Post Reply  
   | 
  
| Author | |
   
   MadRiver  
   
   Groupie  
   Joined: 21 August 2008 Location: United States Status: Offline Points: 22  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Topic: Trying to delete a popup menuPosted: 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...  | 
 |
![]()  | 
 |
   
   Oleg  
   
   Senior Member  
   Joined: 21 May 2003 Location: United States Status: Offline Points: 11234  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     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  | 
 |
![]()  | 
 |
   
   MadRiver  
   
   Groupie  
   Joined: 21 August 2008 Location: United States Status: Offline Points: 22  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     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?  | 
 |
![]()  | 
 |
    Post Reply  
   | 
  |
|       
  
  Tweet   	
    | 
 
| Forum Jump | Forum Permissions  ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum  |