Hello,

I'm starting out as a Palm developer and I'm starting with a simple
example trying to go from one form to another via a button, but I keep
getting the following error: "Form.c, Line:3772, No event handler"

I started off with stationery for a C++ Palm project and augmented it as
I thought it needed, but I must be missing something.  If you have any
advice for me please respond directly to [EMAIL PROTECTED]  The code is
below.

Thankyou,

Graham


                          code for Starter.cpp
_______________________________________________________________________

#include <Pilot.h>
#include <SysEvtMgr.h>
#include "StarterRsc.h"

/***********************************************************************

 *
 *   Internal Structures
 *
 ***********************************************************************/

struct StarterPreferenceType
 {
 Byte replaceme;
 } ;

struct StarterAppInfoType
 {
 Byte replaceme;
 } ;

/***********************************************************************

 *
 *   Internal Constants
 *
 ***********************************************************************/

const unsigned long appFileCreator = 'STRT';
const unsigned short appVersionNum = 0x01;
const unsigned short appPrefID = 0x00;
const unsigned short appPrefVersionNum = 0x01;
const unsigned long version20 = 0x02000000;

/***********************************************************************

 *
 * FUNCTION:    RomVersionCompatible
 *
 * DESCRIPTION: This routine checks that a ROM version is meet your
 *              minimum requirement.
 *
 * PARAMETERS:  requiredVersion - minimum rom version required
 *                                (see sysFtrNumROMVersion in
SystemMgr.h
 *                                for format)
 *              launchFlags     - flags that indicate if the application

 *                                UI is initialized.
 *
 * RETURNED:    error code or zero if rom is compatible
 *
 * REVISION HISTORY:
 *
 ***********************************************************************/

static Err RomVersionCompatible(DWord requiredVersion, Word launchFlags)

{
 DWord romVersion;

 // See if we're on in minimum required version of the ROM or later.
 FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion);
 if (romVersion < requiredVersion)
  {
  if ((launchFlags & (sysAppLaunchFlagNewGlobals |
sysAppLaunchFlagUIApp)) ==
   (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp))
   {
   FrmAlert (RomIncompatibleAlert);

   // Pilot 1.0 will continuously relaunch this app unless we switch to
   // another safe one.
   if (romVersion < version20)
    {
    AppLaunchWithCommand(sysFileCDefaultApp,
sysAppLaunchCmdNormalLaunch, NULL);
    }
   }

  return (sysErrRomIncompatible);
  }

 return (0);
}


/***********************************************************************

 *
 * FUNCTION:    GetObjectPtr
 *
 * DESCRIPTION: This routine returns a pointer to an object in the
current
 *              form.
 *
 * PARAMETERS:  formId - id of the form to display
 *
 * RETURNED:    VoidPtr
 *
 * REVISION HISTORY:
 *
 *
 ***********************************************************************/

static VoidPtr GetObjectPtr(Word objectID)
 {
 FormPtr frmP;

 frmP = FrmGetActiveForm();

 return (FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, objectID)));
}


/***********************************************************************

 *
 * FUNCTION:    MainFormInit
 *
 * DESCRIPTION: This routine initializes the MainForm form.
 *
 * PARAMETERS:  frm - pointer to the MainForm form.
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *
 *
 ***********************************************************************/

static void MainFormInit(FormPtr frmP)
{
}


/***********************************************************************

 *
 * FUNCTION:    MainFormDoCommand
 *
 * DESCRIPTION: This routine performs the menu command specified.
 *
 * PARAMETERS:  command  - menu item id
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *
 *
 ***********************************************************************/

static Boolean MainFormDoCommand(Word command)
{
 Boolean handled = false;


 switch (command)
  {
  case MainOptionsAboutStarterApp:
   handled = true;
   break;

  }
 return handled;
}


/***********************************************************************

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


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

  case frmOpenEvent:
   frmP = FrmGetActiveForm();
   MainFormInit( frmP);
   FrmDrawForm ( frmP);
   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)
{
 Word formId;
 FormPtr frmP;


 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);
    }
    break;

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

   }
  return true;
  }
 else if (eventP->eType == ctlSelectEvent)
  {
   FrmGotoForm(HelloForm);
   return true;
  }

 return false;
}


/***********************************************************************

 *
 * FUNCTION:    AppEventLoop
 *
 * DESCRIPTION: This routine is the event loop for the application.
 *
 * PARAMETERS:  nothing
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *
 *
 ***********************************************************************/

static void AppEventLoop(void)
{
 Word error;
 EventType event;

 Boolean handled = false;

 do {
  EvtGetEvent(&event, evtWaitForever);

  if (! SysHandleEvent(&event))
   if (! MenuHandleEvent(0, &event, &error))
    if (! AppHandleEvent(&event))
     FrmDispatchEvent(&event);

 } while (event.eType != appStopEvent);
}


/***********************************************************************

 *
 * FUNCTION:     AppStart
 *
 * DESCRIPTION:  Get the current application's preferences.
 *
 * PARAMETERS:   nothing
 *
 * RETURNED:     Err value 0 if nothing went wrong
 *
 * REVISION HISTORY:
 *
 *
 ***********************************************************************/

static Err AppStart(void)
{
    StarterPreferenceType prefs;
    Word prefsSize;


 // Read the saved preferences / saved-state information.
 prefsSize = sizeof(StarterPreferenceType);
 if (PrefGetAppPreferences(appFileCreator, appPrefID, &prefs,
&prefsSize, true) !=
  noPreferenceFound)
  {
  }

   return 0;
}


/***********************************************************************

 *
 * FUNCTION:    AppStop
 *
 * DESCRIPTION: Save the current state of the application.
 *
 * PARAMETERS:  nothing
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *
 *
 ***********************************************************************/

static void AppStop(void)
{
   StarterPreferenceType prefs;


 // Write the saved preferences / saved-state information.  This data
 // will be backed up during a HotSync.
 PrefSetAppPreferences (appFileCreator, appPrefID, appPrefVersionNum,
  &prefs, sizeof (prefs), true);
}



/***********************************************************************

 *
 * FUNCTION:    StarterPilotMain
 *
 * DESCRIPTION: This is the main entry point for the application.
 * PARAMETERS:  cmd - word value specifying the launch code.
 *              cmdPB - pointer to a structure that is associated with
the launch code.
 *              launchFlags -  word value providing extra information
about the launch.
 *
 * RETURNED:    Result of launch
 *
 * REVISION HISTORY:
 *
 *
 ***********************************************************************/

static DWord StarterPilotMain(Word cmd, Ptr cmdPBP, Word launchFlags)
{
 Err error;


 error = RomVersionCompatible (version20, launchFlags);
 if (error) return (error);


 switch (cmd)
  {
  case sysAppLaunchCmdNormalLaunch:
   error = AppStart();
   if (error)
    return error;

   FrmGotoForm(MainForm);
   AppEventLoop();
   AppStop();
   break;

  default:
   break;

  }

 return 0;
}


/***********************************************************************

 *
 * FUNCTION:    PilotMain
 *
 * DESCRIPTION: This is the main entry point for the application.
 *
 * PARAMETERS:  cmd - word value specifying the launch code.
 *              cmdPB - pointer to a structure that is associated with
the launch code.
 *              launchFlags -  word value providing extra information
about the launch.
 * RETURNED:    Result of launch
 *
 * REVISION HISTORY:
 *
 *
 ***********************************************************************/

DWord PilotMain( Word cmd, Ptr cmdPBP, Word launchFlags)
{
    return StarterPilotMain(cmd, cmdPBP, launchFlags);
}


Reply via email to