Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!apple!lsr From: lsr@Apple.COM (Larry Rosenstein) Newsgroups: comp.sys.mac.programmer Subject: Re: Problems With Menus Message-ID: <508@internal.Apple.COM> Date: 30 Jan 89 18:32:26 GMT References: <8534@orstcs.CS.ORST.EDU> <6400@hoptoad.uucp> <27812@ucbvax.BERKELEY.EDU> Organization: Advanced Technology Group, Apple Computer Lines: 28 In article <27812@ucbvax.BERKELEY.EDU> oster@dewey.soe.berkeley.edu.UUCP (David Phillip Oster) writes: >I wish people would stop reading and copying all those stupid example >programs that allocate an array, define one set of menu numbers for Agreed. >gets the menu and inserts the menu. It is miles more maintable to just do: > > SetMenuBar(GetNewMBar(128)); > DrawMenuBar(); That's what MacApp does. We even take this a step further and have up to 3 MBAR resources: (1) menus that are loaded and displayed, (2) menus that are loaded but not displayed right away, and (3) menus that are loaded and added to the hierarchical section of the menu bar. >and when the program needs to reference a menu handle, do: > GetMHandle(APPLEMENU); This works as long as that menu is in the menu bar. GetMHandle searches through the menus in the menu bar only (which makes it more efficient that using the Resource Manager). If you don't know for sure that the menu is in the menu bar, then you can call the Resource Manager. (Don't call GetMenu, because that assumes that the menu is in its original form. GetMenu replaces the menu procID with a handle to the defproc. Therefore, GetMenu can't be called more than once with the same menu, unless you take special steps.)