Hide Preferences menu item

From REALbasicWiki

Jump to: navigation, search

 Available on Mac OS only  This article applies only to Mac OS X 

If you don't have the use of a “Preferences” menu item (the one that appears in the “Applications” menu on Mac OS X), you can hide it using this code:

dim menuindex As integer
dim i As integer
dim index As memoryBlock

declare function GetIndMenuItemWithCommandID Lib "Carbon" (inMenu as integer, command as OSType, index as integer, byRef outMenu as integer, outIndex as ptr) as integer
declare function DeleteMenuItem Lib "Carbon" (applicationMenu as integer, item as short) as integer

index=newMemoryBlock(2)
i=getIndMenuItemWithCommandID(0,"pref",1,menuindex,index)
i=deleteMenuItem(menuindex,index.uShort(0))

This code does 2 things:
1: It looks for the menu item which has the "pref" command ID (a command ID being a property of Mac OS menu items). The “Preferences” menu item actually has a command ID with the value "pref".
2: It removes that menu item.

related