Probably a byte vs. word issue somewhere... datum is a UInt16, but if
internally somewhere its turned into a UInt8 it would get transmogrified
into something that looks like a menuCmdBarOpenEvent.

Try using dataum values 255 or less. You can always use dataum[0] and datum
[1] if you need lots of different events. Or use a custom key event (which
is what I use)

- John Schettino

-----Original Message-----
From: Dave Carrigan [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 07, 2002 10:16 AM
To: Palm Developer Forum
Subject: Custom events: possible PalmOS 3.5 bug?


The attached program demonstrates what I think is a PalmOS 3.5 bug. It's
a minimal program that opens a form, adds a custom event to the queue,
and pops up an alert when it sees the custom event.

However, if I set the event's data to the value 262, the program fails.
It appears that something inside PalmOS wants to handle the event,
because the event gets eaten, and a spurious menuCmdBarOpenEvent is
generated. If I use any other value in the data then my form sees the
event and pops up the alert. 

The program works fine under PalmOS 3.3 and 4.0. I also tried it under
PalmOS 3.5.3, but it still fails.

-- 
Dave Carrigan ([EMAIL PROTECTED])            | Yow! I was making donuts and
now
UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-DNS | I'm on a bus!
Seattle, WA, USA                            | 
http://www.rudedog.org/                     | 

------------------------------------------------------------------------
#include <PalmOS.h>

static Boolean 
FormHandleEvent(EventType *e)
{
  Boolean handled = false;
  FormType *frm;
  EventType evt;
    
  frm = FrmGetActiveForm();

  switch (e->eType) {
  case frmOpenEvent: 
    FrmDrawForm(frm);
    MemSet(&evt, sizeof(evt), 0);
    evt.eType = firstUserEvent;
    evt.data.generic.datum[0] = 262;
    EvtAddEventToQueue(&evt);
    handled = true;
    break;

  case firstUserEvent:
    FrmAlert(1000);
    handled = true;
    break;

  default:
    break;
  }

  return handled;
}

static Boolean 
ApplicationHandleEvent(EventType *e)
{
  FormType *frm;
  UInt16 formId;
  Boolean handled = false;

  if (e->eType == frmLoadEvent) {
    formId = e->data.frmLoad.formID;
    frm = FrmInitForm(formId);
    FrmSetEventHandler(frm, FormHandleEvent);
    FrmSetActiveForm(frm);
    handled = true;
  }

  return handled;
}

UInt32
PilotMain(UInt16 cmd, void *cmdPBP, UInt16 launchFlags)
{
  UInt16 err;
  EventType e;

  if (cmd == sysAppLaunchCmdNormalLaunch) {
    FrmGotoForm(1000);
    do {
      EvtGetEvent(&e, evtWaitForever);
      if (! SysHandleEvent (&e))
        if (! MenuHandleEvent (NULL, &e, &err))
          if (! ApplicationHandleEvent (&e))
            FrmDispatchEvent (&e);
    } while (e.eType != appStopEvent);
    FrmCloseAllForms();
  } else {
    return sysErrParamErr;
  }

  return 0;
}

------------------------------------------------------------------------
FORM 1000 0 0 160 160
BEGIN
  TITLE "Main Form"
END

ALERT 1000 
 INFORMATION
BEGIN
  TITLE "All is good"
  MESSAGE "Got the event; all is fine."
  BUTTONS "OK"
END

APPLICATIONICONNAME 1000 "Palm Bug"
VERSION "1.0.0"


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

-- 
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