Hi,

A while ago I found out a way to detect a power off by responding to
hardPowerChr and autoOffChr. Here is my code.

   do {
      // wait for event or tiemout every second
      EvtGetEvent(&e, 100);

      // !!!! zero out data if power goes off !!!!
      if(e.eType == keyDownEvent)
         if(e.data.keyDown.chr == hardPowerChr ||
            e.data.keyDown.chr == autoOffChr)
            DoClearCmd(false);

      // handle any system events
      if(SysHandleEvent(&e))
         continue;

      // handle any menu events (before I get messages)
      if(MenuHandleEvent((void *)0, &e, &err))
         continue;

      // load appropriate form
      if(e.eType == frmLoadEvent) {
         formID = e.data.frmLoad.formID;
         pForm = FrmInitForm(formID);
         FrmSetActiveForm(pForm);
         switch(formID) {
            case FormMain:
               FrmSetEventHandler(pForm, MainEventHandler);
               break;
         }
      }

      // dispatch event to appropriate form
      FrmDispatchEvent(&e);

   } while(e.eType != appStopEvent);

However, I found that if you hold the power button down to toggle the
backlight that my program thinks that the power is going off. Is there a way
to mask this?

Thanks,

Mike McCollister

Michael J. McCollister, Senior Systems Engineer
        Northrop Grumman
        Melbourne, Florida
        Phone: 321-726-7862
        Fax: 321-726-7722
        E-Mail: [EMAIL PROTECTED]

Reply via email to