home *** CD-ROM | disk | FTP | other *** search
- /* Interaction.c */
-
- /* This file demonstrates the techniques necesary for interacting with the user */
- /* when you receive an Apple event. */
-
- #include "AESimple.h"
-
- pascal Boolean MyIdleProc(EventRecord *theEvent, long *sleep, RgnHandle *mouseRgn);
-
- OSErr MyInteractWithUser(Boolean isUrgent)
- {
- NMRec notice;
- Handle mySmallIcon;
- Handle notificationString;
- SignedByte sicnState, strState;
- OSErr err;
-
- /* Set up a notification which blinks a small icon and (optionally) */
- /* shows a dialog to the user. */
- mySmallIcon = Get1Resource('SICN', 128);
- sicnState = HGetState(mySmallIcon);
- HNoPurge(mySmallIcon);
- notificationString = (Handle)GetString(3001);
- strState = HGetState(notificationString);
- MoveHHi(notificationString);
- HLock(notificationString);
-
- notice.qType = nmType;
- notice.nmMark = 1;
- notice.nmIcon = mySmallIcon;
- notice.nmSound = 0L;
- if (isUrgent)
- notice.nmStr = (StringPtr)*notificationString;
- else
- notice.nmStr = 0L;
- notice.nmResp = 0L;
- notice.nmRefCon = 0L;
-
- /* If we're in the background, the next call will either switch us to the front, */
- /* call the Notification Manager, or return an error indicating that user interaction */
- /* is not allowed. */
- /* If interaction is allowed (and we're in the back), this call will wait for our */
- /* application to become frontmost and then return noErr. */
- /* If we're already in front, it returns noErr. */
- err = AEInteractWithUser(kAEDefaultTimeout, (NMRecPtr)¬ice, (IdleProcPtr)MyIdleProc);
- HSetState(mySmallIcon, sicnState);
- HSetState(notificationString, strState);
- return err;
- } /* MyInteractWithUser */
-
-
- /* The following code is taken from CShell, by Keith Rollin and Eric Soldan of Mac DTS. */
- /* (Yes, I have permission to copy it.) */
-
- /* MyIdleProc
- **
- ** This routine gets either an updateEvt, an activateEvt, a nullEvent or an
- ** OSEvent. The first time called it will get a nullEvent; this is its chance
- ** to set the sleep value and mouseRegion that will be passed to WaitNextEvent
- ** by the caller within the AEM. After that it will also get events of the
- ** other types (which are lost if masked out by the AEM) and must do with them
- ** whatever is appropriate.
- */
-
- pascal Boolean MyIdleProc(EventRecord *theEvent, long *sleep, RgnHandle *mouseRgn)
- {
- switch (theEvent->what) {
-
- case updateEvt:
- DoUpdate((WindowPtr)theEvent->message);
- break;
-
- case activateEvt:
- DoActivate(theEvent);
- break;
-
- case app4Evt:
- break;
-
- case nullEvent:
- *mouseRgn = NIL;
- *sleep = 600L; /* 10 seconds */
- break;
- }
- return(false);
- }
-
-
-
-