LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

DiscardMenuItem fail error -11

Solved!
Go to solution

I have a menu that I created in the UI editor and placed on a panel.  I want to programatically remove menu items.  I get error -11 UIEInvalidMenuItemId.  I even tried removing the menu from the panel and loading the menu separately and I still get the error.  When that failed I triedI to set the dimmed atrribute.  That worked.

 

         iMenu = LoadMenuBar(iMainPnl, "140613.uir", MBR_BADGE);
        iTmp = DiscardMenuItem(iMenu, MBR_BADGE_MOTOR);
  

     iTmp = SetMenuBarAttribute(iMenu, MBR_BADGE_MOTOR, ATTR_DIMMED, TRUE);
  

 

CVI 2012 SP1

0 Kudos
Message 1 of 4
(4,660 Views)

This behavior looks correct to me: you can delete menu items or submenus, not menus, that is you need to pass at least a third-level id to the function (menuBarID_menuID_menuItemID or menuBarID_menuID_subMenuID). You can dim a whole menu, instead: every element from the menu that shows on the menu bar up to the last item is dimmed, including all submenus if they exist; other menus in the menu bar are left unchanged).

In your scenario, I suppose MBR is the menu bar ID and MBR_BADGR a menu ID. Menu items should be in the form MBR_BADGR_menuItemID.

 

By the way, error -1 means "the id passed was not a valid menu item id": you can obtain this descriptive string by calling GetGeneralErrorString passing the error number to it.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 4
(4,650 Views)
Solution
Accepted by topic author mjl

Forgot to say that you can use DiscardMenu to delete a menu from the menu bar.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 3 of 4
(4,642 Views)

I was using the wrong command.  I see that my probem was that I thought the menu bar was the menu and didn't realize that each primary entry in the menu bar was a menu.

 

By the way, I was getting error -11 not -1.

 

Regards,

Mike

0 Kudos
Message 4 of 4
(4,611 Views)