home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-01-11 | 2.5 KB | 100 lines | [TEXT/CWIE] |
- //---------------------------------------------------------------------------------------
- //
- // ExtRoutines.c -- Support routines for creating 4D extensions
- //
- // Copyright ©1995-1996, Pensacola Christian College
- //
- // ======================================================================
- // Change History
- // ======================================================================
- //
- // 1.0 08/ /95 Steve Dwire
- // Initial release
- //
- // 1.1 11/17/95 Steve Dwire
- // Added PostKey code from ACIUS's POSTKEY sample extension.
- //
- //---------------------------------------------------------------------------------------
-
- #include "ExtRoutines.h"
-
-
- #if defined(powerc) || WINVER
- Call4DProcPtr gCall4DAdr;
-
- void InitExtension(PackagePtr params)
- {
- // While running on a PowerPC chip or on a Windows station,
- // 4D passes the Call4D address at the InitPackage time:
- gCall4DAdr = ((PackInitPtr)params)->fCall4D;
- }
- #endif
-
- SWORD GetResID(OSType bType, OSType rType, SWORD localID)
- {
- SWORD index, globalID;
- ResTabHdl bundle;
- ParameterBlock block;
-
- CALL4D(kEX_GET_RESID, &block);
-
- bundle = (ResTabHdl)GetResource(bType, block.fParam1);
- if (bundle)
- {
- for (index = 0, globalID = 0; index < (*bundle)->fNumber; index++)
- {
- if(((*bundle)->fEntries[index].fType == rType) &&
- ((*bundle)->fEntries[index].fLocalID == localID))
- globalID = (*bundle)->fEntries[index].fGlobalID;
- }
- HPurge((Handle)bundle);
- }
- return globalID;
- }
-
- #if defined(powerc) || WINVER
- OSErr LaunchNativeProcess (XPOINTER funcName, SLONG stack, UBYTE *procName, SLONG *procID)
- {
- ParameterBlock block;
-
- block.fH = (XHANDLE) funcName;
- block.fParam3 = stack;
- Pstrcpy(procName,block.fS);
- CALL4D(kEX_NEW_PROCESS_PPC, &block);
- *procID = block.fParam1;
- return block.fError;
- }
- #else
- OSErr Launch68KProcess (SLONG resType, SLONG resID, SLONG stack, UBYTE *procName, SLONG *procID)
- {
- ParameterBlock block;
- XHANDLE procResource;
-
- procResource = GetResource(resType,GetResID('4BNX',resType,resID));
-
- HNoPurge(procResource);
- HLock(procResource);
-
- block.fH = (XHANDLE) *procResource;
- block.fParam3 = stack;
- Pstrcpy(procName,block.fS);
- CALL4D(kEX_NEW_PROCESS, &block);
- *procID = block.fParam1;
- return block.fError;
- }
- #endif
-
- void PostKey( unsigned long TheKey, unsigned long TheModifiers, Boolean useAutoKey)
- {
- OSErr TheErr;
- long TheMessage;
- EvQEl *TheQElPtr;
-
- TheMessage = TheKey & charCodeMask;
- if (useAutoKey)
- TheErr = PPostEvent(autoKey,TheMessage,&TheQElPtr);
- else
- TheErr = PPostEvent(keyDown,TheMessage,&TheQElPtr);
- TheQElPtr->evtQModifiers = TheModifiers;
- }
-