tags:

views:

729

answers:

1

I can get the menu handle from CreateNibReference function, but I don't know how to hide or disable menu item with the handle in Mac OS X?

+2  A: 

It sounds like you're using the Carbon Menu Manager. In that case, if you have a MenuRef instance, you call DisableMenuItem(), passing the index of the menu item, to disable a menu item:

DisableMenuItem(menuRef, itemIndex);

As expected, call EnableMenuItem() to enable the item again.

As far as I am aware, there is no way to "hide" a menu item with the Carbon Menu Manager. The closest thing I can think of would be removing a menu item, in which case you would use DeleteMenuItem():

DeleteMenuItem(menuRef, itemIndex);

See Apple's Menu Manager documentation for more detailed information on how to use these functions.

Also, as a side note, it is generally advisable to use Cocoa instead of Carbon for most applications. Carbon is being visibly phased out by Apple, and it might not be long before Apple deprecates it entirely.

htw
Carbon isn't deprecated, you know. Not yet, anyway...
Coxy
Whoops, sorry about that. Yeah, I think I was thinking of QuickDraw for some reason…anyways, post fixed.
htw