Hi,

I am trying to create a little popup dialog that will
capture the next key stroke.  I can bring up the
dialog using FrmDoDialog.  FrmDoDialog will return the
the ID of the cancel button if the cancel button is
pressed.  However, I can't get the dialog to exit if a
key is pressed and then return something like 0 to let
me know that Cancel was not pressed.  I can capture
the keystroke and I've tried to send another event to
tell it to return but do no avail.  Does anyone have
any ideas on how to do this?

Here is some source code to show you what I am trying
to do:


static void CustomButtonDoDialog(FormPtr pCurrentForm)
{
   FormPtr pForm;
   UInt16 fred; // ???

   // init form
   pForm = FrmInitForm(CustomButtonForm);

   // set new form
   FrmSetActiveForm(pForm);

   // set alarm form event handler
   FrmSetEventHandler(pForm,
CustomButtonEventHandler);

   // initialize and draw the form
   CustomButtonInit(pForm);
   FrmDrawForm(pForm);

   // now wait for alarm form to exit
   fred = FrmDoDialog(pForm);
{  // debug code
   Char sTemp[20];
   StrPrintF(sTemp, "fred = %d", fred);
   SysFatalAlert(sTemp);
}

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

Boolean CustomButtonEventHandler(EventPtr event)
{
   FormPtr pForm = FrmGetActiveForm();
   Boolean handled = true;
   EventType csEvent;

   switch(event->eType) {
/* Not used
      case frmOpenEvent:
         ActivationInit(pForm);
         FrmDrawForm(pForm);
         break;
      
*/
      case frmUpdateEvent:
         FrmDrawForm(pForm);
         break;

      case ctlSelectEvent:
         switch(event->data.ctlEnter.controlID) {
            case CancelButton:
               break;
         }
         handled = false;
         break;

      case keyDownEvent:
         // UGH!!!
         DEBUG_BEEP;
         csEvent.eType = ctlSelectEvent;
         csEvent.data.ctlEnter.controlID = 0; // ???
         EvtAddEventToQueue(&csEvent);
         // handled = false; // allows for the display
to be updated properly
         // ??? FrmEraseForm(pForm);
         // ??? FrmDeleteForm(pForm);
         handled = false;
         break;

      case frmCloseEvent:
         FrmEraseForm(pForm);
         FrmDeleteForm(pForm);
         break;

      default:
         handled = false;
         break;
   }
   
   return handled;
}

Thanks for attention and help.

Regards,

Mike McCollister

__________________________________________________
Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards�
http://movies.yahoo.com/

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to