Hi,

I have a program that pops up an alarm. I used to just pop up a
FrmCustomAlert. However, I have changed it so that a whole form comes up.
Now I have never done this before and found some example code on the
Internet. I have some questions about this code that will be greatly
appreciated. This is the code that I have (please see the lines with "???"
in them for specific questions).

static void RaiseAlarm(void)
{
   /* snip: removed variable declaration for space */
   /* snip: removed some code to create message in sAlarmMessage */

   pForm = FrmInitForm(formID_alarm);

   pCurrentForm = FrmGetActiveForm();  // ??? do I need to save the current
form
   if(pCurrentForm)
      FrmSetActiveForm(pForm);
   FrmSetEventHandler(pForm, AlarmEventHandler);  // ??? my form only has an
OK button on it, do I need to set the event handler?

   // set alarm message
   hAlarmMessage   = MemHandleNew(NUM_ALARM_STAT_CHARS + 1);
   StrCopy(MemHandleLock(hAlarmMessage), sAlarmMessage);
   MemHandleUnlock(hAlarmMessage);
   FldSetTextHandle(Id2Ptr(fieldID_alarmMessage), (Handle)hAlarmMessage);

   // draw the form
   FrmDrawForm(pForm);

   // bring up dialog
   FrmDoDialog(pForm);

   // now clean up form
   FrmEraseForm(pForm);
   FrmDeleteForm(pForm);
   FrmSetActiveForm(pCurrentForm);

// ???   MemHandleFree(hAlarmMessage);  // ??? crash and burn if this line
is in.

   /* snip: removed some alarm data manipulation */   
}


static Boolean AlarmEventHandler(EventPtr event)
{
   Boolean handled = true;

   if(event->eType != appStopEvent)
      handled = false;

   return handled;
}

Thanks all for your help and comments.

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