home *** CD-ROM | disk | FTP | other *** search
- /*
-
- cdev code stub for MetroWerks CodeWarrior
- by Joe Zobkiw (aflzobkiw@aol.com)
-
- MetroWerks CodeWarrior is a great little compiler/environment.
-
- Unfortunately a bug exists in the current version that doesn't allow you
- to set the ID of a code-bearing resource to a negative number. This
- makes it very difficult to work on a cdev (control panel device) using
- CodeWarrior. Until now...
-
- Compile the following code "stub" in CodeWarrior, manually set it's ID to
- -4064, then paste it into your control panels resource file. You can now use
- CodeWarrior to work on your real control panel code resource which you will
- now give ID 4064 (instead of -4064.) When the Finder launches your control
- panel, it will call the stub code in -4064 which will load and "call through"
- to your _real_ code in 4064. Voila!
-
- Finder ---> -4064 stub ---> 4064 (your code)
-
- If you like, you can leave this stub in place forever, it will work fine.
- I would suggest using it until the bug in MetroWerks is fixed, simply to
- save you time. Enjoy and please let me know if there are any problems
- that you encounter. I've tested this on numerous cdevs and it seems to work
- fine.
-
- Questions, comments, etc. welcome.
-
- */
-
- typedef pascal long (*cdevProc)( short message,
- short item,
- short numItems,
- short CPanelID,
- EventRecord *theEvent,
- Handle cdevStorage,
- DialogPtr CPDialog);
-
- pascal long main( short message,
- short item,
- short numItems,
- short CPanelID,
- EventRecord *theEvent,
- Handle cdevStorage,
- DialogPtr CPDialog)
- {
- long returnValue = cdevMemErr; /* initialize to the worst */
- Handle h = Get1Resource('cdev', 4064); /* load in our _real_ code */
-
- if (h != NULL) {
- MoveHHi(h); /* move it high */
- HLock(h); /* lock it down */
- returnValue = ((cdevProc)(*h))( message, /* call it */
- item,
- numItems,
- CPanelID,
- theEvent,
- cdevStorage,
- CPDialog);
- HUnlock(h); /* the unlock */
- ReleaseResource(h); /* and the release */
- }
-
- return returnValue; /* return whatever */
- }
-