here's a piece of code that is crashing the system (from a Codewarrior C++
app skeleton)
It is similar to the call structure I have.
If I call the drawing code from withing the AppHandleEvent, it will NOT
work.
Only if I call it from FrmDrawOpen will it work.
Why is that?
Can the system be changing the current drawing window without changing it
back to
the main form?

/***********************************************************************
 *
 * FUNCTION:    MainFormHandleEvent
 *
 * DESCRIPTION: This routine is the event handler for the
 *              "MainForm" of this application.
 *
 * PARAMETERS:  eventP  - a pointer to an EventType structure
 *
 * RETURNED:    true if the event has handle and should not be passed
 *              to a higher level handler.
 *
 * REVISION HISTORY:
 *
 *
 ***********************************************************************/
static Boolean MainFormHandleEvent(EventPtr eventP)
{
   Boolean handled = false;
   FormPtr frmP;
   RectangleType rc;

 switch (eventP->eType)
  {
  case menuEvent:
   return MainFormDoCommand(eventP->data.menu.itemID);

  case frmOpenEvent:
   frmP = FrmGetActiveForm();
   MainFormInit( frmP);
   FrmDrawForm ( frmP);

  rc.topLeft.x = rc.topLeft.y = 15;
  rc.extent.x = rc.extent.y = 25;
  WinDrawRectangleFrame(rectangleFrame, &rc);

   handled = true;
   break;

  default:
   break;

  }

 return handled;
}


/***********************************************************************
 *
 * FUNCTION:    AppHandleEvent
 *
 * DESCRIPTION: This routine loads form resources and set the event
 *              handler for the form loaded.
 *
 * PARAMETERS:  event  - a pointer to an EventType structure
 *
 * RETURNED:    true if the event has handle and should not be passed
 *              to a higher level handler.
 *
 * REVISION HISTORY:
 *
 *
 ***********************************************************************/
static Boolean AppHandleEvent(EventPtr eventP)
{
 UInt16 formId;
 FormPtr frmP;
 RectangleType rc;

 if (eventP->eType == frmLoadEvent)
 {
  // Load the form resource.
  formId = eventP->data.frmLoad.formID;
  frmP = FrmInitForm(formId);
  FrmSetActiveForm(frmP);

  // Set the event handler for the form.  The handler of the currently
  // active form is called by FrmHandleEvent each time is receives an
  // event.
  switch (formId)
   {
   case MainForm:
    FrmSetEventHandler(frmP, MainFormHandleEvent);
/* DOES NOT WORK
  rc.topLeft.x = rc.topLeft.y = 15;
  rc.extent.x = rc.extent.y = 25;
  WinDrawRectangleFrame(rectangleFrame, &rc);
*/
    break;

   default:
//    ErrFatalDisplay("Invalid Form Load Event");
    break;

   }
  return true;
 }
 else if ( eventP->eType == frmOpenEvent )
 {
/* DOES NOT WORK
  rc.topLeft.x = rc.topLeft.y = 15;
  rc.extent.x = rc.extent.y = 25;
  WinDrawRectangleFrame(rectangleFrame, &rc);
*/
 }

 return false;
}


- Darren Lee Ang




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

Reply via email to