jtt@cunixd.cc.columbia.edu (James T. Tanis) (12/16/90)
I've been banging my head up against this problem for a while now-- I've got a (popup) menu that gets modified during the course of execution. At a certain point, I'd liek to reset it to it's original state. I've tried everything I can think of, but only get errors. It seems that the menu is gotten from the Resource correctly the first time. then, when it is time to reset it, I release the resource, and load it again. now, the item list is read in correctly, but the defProc is not, thus the sizes are not calculated correctly. HAS ANYBODY BEEN SUCESSFUL AT THIS SORT OF THING? Thanks! -JT
beard@ux5.lbl.gov (Patrick C Beard) (12/16/90)
In article <1990Dec16.034906.25332@cunixf.cc.columbia.edu> jtt@cunixd.cc.columbia.edu (James T. Tanis) writes:
#I've been banging my head up against this problem for a while now--
#
#I've got a (popup) menu that gets modified during the course of execution.
#At a certain point, I'd liek to reset it to it's original state.
#I've tried everything I can think of, but only get errors. It seems that
#the menu is gotten from the Resource correctly the first time.
#then, when it is time to reset it, I release the resource, and load it
#again.
#now, the item list is read in correctly, but the defProc is not, thus the
#sizes are not calculated correctly.
#
#HAS ANYBODY BEEN SUCESSFUL AT THIS SORT OF THING?
#
#Thanks!
#-JT
#
Be sure to zero out the defProc field of the MenuHandle before writing it
out. On 68000 Mac's a non-zero defProc will cause a crash.
--
-------------------------------------------------------------------------------
- Patrick Beard, Macintosh Programmer (beard@lbl.gov) -
- Berkeley Systems, Inc. ".......<dead air>.......Good day!" - Paul Harvey -
-------------------------------------------------------------------------------
oster@well.sf.ca.us (David Phillip Oster) (12/17/90)
The menu manager reads the menu resource into memory, then modifies it. If the resoure is purged, the reread, these necessary modifications will not have been done on the new copy, and your program will crash. What you can do is, preserve the state of the menu, when it is good, in another handle, then reset it later. I use a routine like BlockMove, that makes one handle match another. here it is: /* HandleMove - copy all the data from src to dest. */ OSErr HandleMove(src, dest)Handle src, dest;{ LongInt len; OSErr val; #if STRICT if(NIL == src || NIL == dest){ DebugStr((StringPtr) "\pCan't happen in HandleMove"); } #endif val = noErr; if(NIL == dest){ return noErr; } if(NIL == src){ SetHandleSize(dest, 0); return MemError(); } len = GetHandleSize(src); if(len != GetHandleSize(dest)){ SetHandleSize(dest, len); if(noErr != (val = MemError())){ return val; } } BlockMove(*src, *dest, len); return noErr; } -- -- David Phillip Oster - At least the government doesn't make death worse. -- oster@well.sf.ca.us = {backbone}!well!oster
Chris.Gehlker@p12.f56.n114.z1.fidonet.org (Chris Gehlker) (12/24/90)
DPO> The menu manager reads the menu resource into memory, then modifies DPO> it. If the resoure is purged, the reread, these necessary modifications DPO> will not have been done on the new copy, and your program will DPO> crash. What you can do is, preserve the state of the menu, when DPO> it is good, in another handle, then reset it later. I use a routine DPO> like BlockMove, that makes one handle match another. Why all the BlockMove stuff? What's wrong with HandToHand? -- Uucp: ...{gatech,ames,rutgers}!ncar!asuvax!stjhmc!56.12!Chris.Gehlker Internet: Chris.Gehlker@p12.f56.n114.z1.fidonet.org