Important: The information in this document is obsolete and should not be used for new development.
GetMenu
Use theGetMenufunction to create a menu with the title, items, and other characteristics defined in a'MENU'resource with the specified resource ID. You typically use this function only when you create submenus; you can create all your pull-down menus at once using theGetNewMBarfunction, and you can create pop-up menus using the standard pop-up control definition function.
FUNCTION GetMenu (resourceID: Integer): MenuHandle;
resourceID- The resource ID of the
'MENU'resource that defines the characteristics of the menu. (You usually use the same number for a menu's resource ID as the number that you specify for the menu ID in the menu resource.)DESCRIPTION
TheGetMenufunction creates a menu according to the specified menu resource, and it also creates a menu record for the menu. It reads the menu definition procedure (specified in the menu resource) into memory if it isn't already in memory, and it stores
a handle to the menu definition procedure in the menu record. TheGetMenufunction does not insert the newly created menu into the current menu list.After reading the
'MENU'resource, theGetMenufunction searches for an'mctb'resource with the same resource ID as the'MENU'resource. IfGetMenufinds this'mctb'resource, it uses the information in the'mctb'resource to add entries for this menu to the application's menu color information table. TheGetMenufunction usesSetMCEntriesto add the entries defined by the'mctb'resource to the application's menu color information table. IfGetMenudoesn't find this'mctb'resource, it uses the default colors specified in the menu bar entry of the application's menu color information, or, if the menu bar entry doesn't exist, it uses the standard colors for
the menu.The
GetMenufunction returns a handle to the menu record of the menu. You can use the returned menu handle to refer to this menu in most Menu Manager routines. IfGetMenuis unable to read the menu or menu definition procedure from the resource file,GetMenureturnsNIL.After creating a menu with
GetMenu, you can useAppendMenu,InsertMenuItem,AppendResMenu, orInsertResMenuto add more menu items to the menu if necessary.To add a menu created by
GetMenuto a menu list, use theInsertMenuprocedure. To update the menu bar with any new menu titles, use theDrawMenuBarprocedure.Storing the definitions of your menus in resources (especially menu titles and menu items) makes your application easier to localize.
- WARNING
- Menus in a resource must not be purgeable.
![]()
SPECIAL CONSIDERATIONS
To release the memory associated with a menu that you read from a resource file usingGetMenu, first callDeleteMenuto remove the menu from the menu list and to remove any menu title entry or menu item entries for this menu in the application's menu color information table, then call the Resource Manager procedureReleaseResourceto dispose of the menu's menu record. UseDrawMenuBarto update the menu bar.
- WARNING
- Call
GetMenuonly once for a particular menu. If you need the handle of a menu currently in the menu list, useGetMenuHandleor the Resource Manager functionGetResource.![]()
SEE ALSO
For a description of the'MENU'resource, see "The Menu Resource" on page 3-154; for a sample'MENU'resource in Rez format, see Listing 3-2 on page 3-48. For information on the'mctb'resource, see "The Menu Color Information Table Resource" on page 3-157.For details on how to add items to a menu, see the description of
AppendMenuon page 3-126,InsertMenuItemon page 3-128,AppendResMenuon page 3-130, andInsertResMenuon page 3-131. To remove a menu, see the description ofDeleteMenuon page 3-111. To update the menu bar, use theDrawMenuBarprocedure, described on page 3-115.