Path: utzoo!attcan!uunet!husc6!bbn!uwmcsd1!ig!agate!garnet.berkeley.edu!elcond From: elcond@garnet.berkeley.edu (Gregory Dow) Newsgroups: comp.sys.mac.programmer Subject: Re: Custom menu bars Message-ID: <10256@agate.BERKELEY.EDU> Date: 24 May 88 09:01:16 GMT References: <10241@agate.BERKELEY.EDU> Sender: usenet@agate.BERKELEY.EDU Organization: University of California, Berkeley Lines: 45 In article <10241@agate.BERKELEY.EDU> lippin@math.berkeley.edu writes: >I started working on a custom MBDF yesterday, and so for the first >time closely examined that part of IM V's menu manager chapter. The >MBDF is to be declared as returning a LONGINT, but one of the >messages, GetRect (or just Rect, depending on where you look) would >have it return a Rect. Now, last I heard, Pascal doesn't have >provisions for returning record types, but I can ignore that, because >I'm writing in C. But I still can't cram a Rect into a LONGINT; it's >just too big. I also thought of returning a pointer to the Rect, but >then where would I put the Rect? In the MBDF's copious global >storage? Or on the heap, where it might never be disposed of? > >Anyone know what the deal is here? > > --Tom Lippincott > ..ucbvax!math!lippin > > "We DEMAND solid facts!" --Vroomfondel You must pass back a pointer to a Rect in response to the GetRect message. The system MBDF stores this Rect in a low-memory global. It uses the Scratch8 global at address $9FA. The system MBDF also allocates space for itself in the system heap. For my own custom MBDF, I use a custom resource of type myMB with the same ID as the MBDF to hold my data. This myMB resource is pre-loaded and locked in the application heap. I can then use this space to store all the variables my MBDF needs. I have an 8 byte section in this block where I store the Rect whose address is returned for a GetRect message. The use of the Scratch8 global by the system MBDF is undocumented, so I didn't want to rely on that method. Of course, if you want to use your MBDF for more than just your own application (such as replacing the system's MBDF), you'll have to carve out some space for yourself in the system heap and find a place to store a pointer to it (the system MBDF uses the low-memory location $B5C -- also undocumented). I got this information by looking at the assembly language source code for the system MBDF which is available on AppleLink, and by stepping through the MDBF in ROM using TMON. Writing an MBDF is not a pleasant or easy task. Good Luck. Gregory Dow ARPA: elcond@garnet.berkeley.edu Chemical Engineering Dept. UUCP: {uwvax, decvax, ihnp4, ...}!ucbvax University of California !elcond%garnet.berkeley.edu Berkeley, CA 94720 BITNET: POLYDOW@UCBCMSA