home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 June / MacFormat 25.iso / Shareware City / Developers / appe Windows 1.51.1 / aevents.c < prev    next >
Encoding:
Text File  |  1995-04-05  |  2.8 KB  |  94 lines  |  [TEXT/KAHL]

  1. // File "aevents.c" - Basic High Level Event Processing
  2. // This source file is Copyright Matt Slot & Slot-Machines Ltd., © 1993
  3.  
  4. #include "aevents.h"
  5. #include "main.h"
  6.  
  7. // ***********************************************************************************
  8.  
  9. extern GlobalsRec glob;
  10.  
  11. // ***********************************************************************************
  12. // ***********************************************************************************
  13.  
  14. pascal short AEHandlerOAPP(AppleEvent *event, AppleEvent *reply, long refCon) {
  15.  
  16.     return(0);
  17.     }
  18.     
  19. // ***********************************************************************************
  20. // ***********************************************************************************
  21.  
  22. pascal short AEHandlerODOC(AppleEvent *event, AppleEvent *reply, long refCon) {
  23.     short errorCold, i;
  24.     long count;
  25.     Str63 textBuff;
  26.     Size returnedSize;
  27.     DescType returnedType;
  28.     AEKeyword returnedKeyword;
  29.     AEDescList docList;
  30.     FSSpec theFile;
  31.     
  32.     errorCold = AEGetParamDesc(event, keyDirectObject, typeAEList, &docList);
  33.     if (errorCold) return(errorCold);
  34.     
  35.     errorCold = AECountItems(&docList, &count);
  36.     for(i = 1; i <= count; i++) {
  37.         errorCold = AEGetNthPtr(&docList, i, typeFSS, &returnedKeyword, 
  38.                 &returnedType, (Ptr) &theFile, sizeof(theFile), &returnedSize);
  39.         
  40.         }
  41.         
  42.     return(0);
  43.     }
  44.     
  45. // ***********************************************************************************
  46. // ***********************************************************************************
  47.  
  48. pascal short AEHandlerPDOC(AppleEvent *event, AppleEvent *reply, long refCon) {
  49.  
  50.     return(0);    
  51.     }
  52.     
  53. // ***********************************************************************************
  54. // ***********************************************************************************
  55.  
  56. pascal short AEHandlerQUIT(AppleEvent *event, AppleEvent *reply, long refCon) {
  57.  
  58.     glob.quitting = 1;
  59.     return(0);
  60.     }
  61.     
  62. // ***********************************************************************************
  63. // ***********************************************************************************
  64.  
  65. void InitHLEvents() {
  66.     short i=0, errorCold=0;
  67.     AEHandlers *handlerArray;
  68.  
  69.     handlerArray=(AEHandlers*) NewPtrClear(4 * sizeof(AEHandlers));
  70.     
  71.     handlerArray[0].theClass=kCoreEventClass;
  72.     handlerArray[0].theEvent=kAEOpenApplication;
  73.     handlerArray[0].theProc=AEHandlerOAPP;
  74.  
  75.     handlerArray[1].theClass=kCoreEventClass;
  76.     handlerArray[1].theEvent=kAEOpenDocuments;
  77.     handlerArray[1].theProc=AEHandlerODOC;
  78.  
  79.     handlerArray[2].theClass=kCoreEventClass;
  80.     handlerArray[2].theEvent=kAEPrintDocuments;
  81.     handlerArray[2].theProc=AEHandlerPDOC;
  82.  
  83.     handlerArray[3].theClass=kCoreEventClass;
  84.     handlerArray[3].theEvent=kAEQuitApplication;
  85.     handlerArray[3].theProc=AEHandlerQUIT;
  86.     
  87.     for(i=0; i<4; i++)  errorCold=AEInstallEventHandler(handlerArray[i].theClass,
  88.             handlerArray[i].theEvent,handlerArray[i].theProc,0,0);
  89.         
  90.     DisposPtr((Ptr) handlerArray);
  91.     }
  92.  
  93.  
  94.