04-03-2015 01:40 PM
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
Solved! Go to Solution.
04-04-2015 03:03 AM
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.
04-04-2015 07:01 AM
Forgot to say that you can use DiscardMenu to delete a menu from the menu bar.
04-06-2015 08:20 AM
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