Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - How to delete menu item using parent
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How to delete menu item using parent

 Post Reply Post Reply
Author
Message
sandy eggo View Drop Down
Newbie
Newbie


Joined: 14 November 2007
Location: Albania
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote sandy eggo Quote  Post ReplyReply Direct Link To This Post Topic: How to delete menu item using parent
    Posted: 14 November 2007 at 5:27pm
I have an app that dynamically adds menu items based on the contents of a directory. Sub-Directories are added to the menu as sub-menu popups and files are added as menu items. My problem is that when the user elects to re-load the menu I have to remove all the dynamically added menu items without removing the compile-time menu items. So the problem is that I can't delete the empty menus after the sub items have been deleted. 
 
See the following code. The problem is the last line:
 

XtremeCommandBars.CommandBarControl foundMenuItem = null;

// check to see if the custom menu item exists in the FTM Commands menu

foundMenuItem = ControlMode.CommandBar.FindControl(

XTPControlType.xtpControlButton, IDNum, true, true );

if( foundMenuItem != null )

{

// get the parent menu of the found item for future check

XtremeCommandBars.CommandBar parentMenu =

(XtremeCommandBars.CommandBar)foundMenuItem.Parent;

// delete the item from the menu

foundMenuItem.Delete();

// delete the parent menu if there are no items left in it

if( parentMenu.Controls.Count <= 0 )

{

parentMenu.Delete(); // THIS DOESN'T WORK

}

 

sandy eggo
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.188 seconds.