home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!cs.utexas.edu!sun-barr!ames!data.nas.nasa.gov!taligent!kip-50.taligent.com!user
- From: keith@taligent.com (Keith Rollin)
- Subject: Re: Calling external code resources - how?
- Message-ID: <keith-240193175414@kip-50.taligent.com>
- Followup-To: comp.sys.mac.programmer
- Sender: usenet@taligent.com (More Bytes Than You Can Read)
- Organization: Taligent
- References: <01050014.odph61@blanc.north.de>
- Date: Mon, 25 Jan 1993 01:59:02 GMT
- Lines: 63
-
- In article <01050014.odph61@blanc.north.de>, jochen@blanc.north.de (Jochen
- Meyer) wrote:
- >
- > I am currently writing a program that I want to be extensible. The
- > most common way of handling extensibility seems to be using external
- > code resources, like in Canvas or BBEdit.
- >
- > Where can I find information on how to do this? The Segment Manager
- > chapter of IM gives no clues on this. Anyone has got some sample code
- > on this?
-
- If you have Technote #256, read it. If you don't, log onto ftp.apple.com,
- go to /dts/mac/tn/patforms.tools and download the file called
- stand-alone-code.hqx. It will tell you just what you want.
-
- Just to whet your appetite, here's some code that I use to call CDEF's
- directly:
-
-
- typedef pascal long (*CDEFProc)(short varCode, ControlHandle theControl,
- short msg, long param);
-
- long CallCDEF(ControlHandle theControl, short msg, long param)
- {
- CDEFProc* defProcHandle;
- GrafPtr oldPort;
- char oldState;
- long result;
-
- defProcHandle = (CDEFProc*) StripAddress((**theControl).contrlDefProc);
-
- if (defProcHandle != nil) {
-
- if (*defProcHandle == nil) {
- LoadResource((Handle) defProcHandle);
- }
-
- if (*defProcHandle != nil) {
-
- GetPort(&oldPort);
- SetPort((**theControl).contrlOwner);
-
- oldState = HGetState((Handle) defProcHandle);
- HLock((Handle) defProcHandle);
-
- result = (*defProcHandle)(GetCVariant(theControl), theControl, msg,
- param);
-
- HSetState((Handle) defProcHandle, oldState);
- SetPort(oldPort);
-
- return result;
- }
- }
-
- SysError(dsCDEFNotFound);
- }
-
-
- -----
- Keith Rollin
- Phantom Programmer
- Taligent, Inc.
-