Path: utzoo!attcan!uunet!tank!uxc!iuvax!mailrus!ames!pasteur!ucbvax!dewey.soe.berkeley.edu!oster From: oster@dewey.soe.berkeley.edu (David Phillip Oster) Newsgroups: comp.sys.mac.programmer Subject: Re: Help!! ?Changed Menu Made Permanent? Keywords: Menu Resource Message-ID: <27319@ucbvax.BERKELEY.EDU> Date: 3 Jan 89 19:35:56 GMT References: <1115@ccnysci.UUCP> Sender: usenet@ucbvax.BERKELEY.EDU Reply-To: oster@dewey.soe.berkeley.edu.UUCP (David Phillip Oster) Distribution: comp.sys.mac.programmer Organization: School of Education, UC-Berkeley Lines: 32 In article <1115@ccnysci.UUCP> cpyang@ccnysci.UUCP (Chao Ping Yang) writes: >doing ResEdit shows the MenuResource is properly saved. >On the other hand, I have no problem with other resource >being changed, like the STR#. > >Can somebody help me out on this? The problem has to do with punning that occurs with menu resources and not with other resources. There is a LongInt field of the resoure that holds, on disk, the resource id of the MDEF that runs this menu, and, in memory, a handle to the actual MDEF. What this means is, if you write the in memory copy to disk, the disk version will have a garbage MDEF field. If you set up the in memory version, then write it out, if you don't restore the in memory value, the in memory version will crash. 1.) You can detach the in memory version, copy it, fix the copy and do an AddResource. 2.) You can build your menus at run time from strings. Then just modify the constructor string. 3.) You can change the in-memory copy, write it out, then change it back. The MenuManager was first written a very long time ago, at that time it wasn't quite clear how resources should be used. as a result, this the-field-has-different-meanings-on-disk-versus-in-memory got in. A more modern system would have added an extra Integer field for the MDEF id, and had a 4-byte filler, that would be filled in when the structure got read into memory. Too late to change it now, it would break too many programs that depend on the current structure of a menu. --- David Phillip Oster --"When we replace the mouse with a pen, Arpa: oster@dewey.soe.berkeley.edu --3 button mouse fans will need saxophone Uucp: {uwvax,decvax}!ucbvax!oster%dewey.soe.berkeley.edu --lessons." - Gasee