Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Using IAlarmMgr in an application

To use IAlarmMgr functions, an application must first create an instance of IAlarmMgr. For example:

if (ISHELL_CreateInstance(pMe->piShell, AEECLSID_ALARMMGR,
            (void **)&pMe->piAlarmMgr) != SUCCESS) {
   pMe->piAlarmMgr = NULL;
   return FALSE;
}

The application can then set one or more alarms. For example:

   int nErr;
   uint32 nSecs = 120;
   uint32 UserCode = 0;

   nErr = IALARMMGR_SetAlarm(pMe->piAlarmMgr, AEECLSID_C_TIME_EXAMPLES,
               &UserCode, nSecs);
   if (AEE_SUCCESS != nErr) {
      return FALSE;
   }

   return TRUE;

The application will receive an EVT_ALARM event when the alarm expires, and can take the appropriate action. In this example, EVT_ALARM is added to the event handler function for the application and a message is displayed when the alarm expires:

      case EVT_ALARM:
         c_time_examples_DisplayMessage(pMe, IDS_STRING_1005, IDF_ALIGN_MIDDLE);
         break;