Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!apple!sun-barr!decwrl!shelby!portia!jessica!duggie From: duggie@jessica.Stanford.EDU (Doug Felt) Newsgroups: comp.sys.mac.programmer Subject: Re: control definition functions without CDEFs? Message-ID: <10098@portia.Stanford.EDU> Date: 13 Mar 90 01:30:49 GMT References: <423@fornax.UUCP> <8013@tank.uchicago.edu> Sender: USENET News System Reply-To: duggie@jessica.Stanford.EDU (Doug Felt) Distribution: na Organization: Stanford University Lines: 35 In article <8013@tank.uchicago.edu> asl2@tank.uchicago.edu (Aaron "Fish" Lav) writes: >In article <423@fornax.UUCP> mcdonald@fornax.UUCP (Ken Mcdonald) writes: >>I'm writing up a bit of source which, eventually, I'd like to distribute. It >>uses custom CDEFs, but one thing I'd like to do is to avoid making users >>of the source copy extra CDEFs into their applications--that is, I'd like >>to build the custom controls entirely within the source. The first >>mcdonald@cs.sfu.ca > >What you want to do is allocate a six-byte handle, and fill that with a jump >to your procedure's address. There was a Mactutor example of how to do this >. If you want I'll try to find it and/or reproduce it. >The handle's contents should be $4EF9 (jmp to 32-bit immed. addr), and then >your procedure address. >That's the way to avoid using fake handles. > > Aaron <><| >asl2@tank.uchicago.edu Make sure, by the way, that the procedure is in a segment that will stay locked while the control is in use. Perhaps an even better alternative is to dispense with controls altogether and implement the routines in your own code. After you've written the CDEF basically all that's left is TrackControl, so you might as well write everything yourself. This not only makes your code cleaner and easier to read, it makes it easier to provide additional functionality as well (i.e. controls with floating point values, or multiple independent values, or lots of parameters). In my opinion CDEFs aren't worth the hassle unless you need to replace controls in apps for which you don't have the source. Doug Felt