Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!apple!Apple.COM!lsr From: lsr@Apple.COM (Larry Rosenstein) Newsgroups: comp.sys.mac.programmer Subject: Re: Append menu is slow. Message-ID: <1757@internal.Apple.COM> Date: 10 May 89 17:05:33 GMT Sender: usenet@Apple.COM Organization: Objects-R-Us, Apple Computer, Inc. Lines: 29 References:<89May9.171757edt.11077@ephemeral.ai.toronto.edu> <29122@ucbvax.BERKELEY.EDU> In article <29122@ucbvax.BERKELEY.EDU> oster@dewey.soe.berkeley.edu (David Phillip Oster) writes: > AppendMenu doesn't know that you are going to be calling it again > immediately, so it calls CalcMenuSize(), which does a linear scan over > the menu to see how wide the menu should be by doing a StringWidth() on > each item. That is likely the problem. > the end of the muenu is a null byte. You can use Munger to insert items > into a menu, then call CalcMenuSize() yourself after you are all done. A better approach (one used in MacApp) is to temporarily replace the menu defproc handle in the menu with a handle to a dummy defproc that does'nt do anything for calculating the menu size. Then call the normal Menu Manager routines to add the menus, restore the defproc handle, and call CalcMenuSize manually. This doesn't require that you parse or rely on the format of a menu. Be sure to create a real handle, and put a 6-byte JMP instruction in it. Alternatively, you could compile a dummy MDEF and put the MDEF resource into your application. Larry Rosenstein, Apple Computer, Inc. Object Specialist Internet: lsr@Apple.com UUCP: {nsc, sun}!apple!lsr AppleLink: Rosenstein1