Hi,
In my code, a tries to load a new form, chosen from a list.
FormCloseEvent passes for the 'old' form, but my application
stops at WinExitEvent. (NULL FORM).
Could anyone help me to figure out what is wrong ?
Christer
/my code
#include <Pilot.h> // all the system toolbox
headers
#include "ilrresources.h" // application resource
defines
#include "lists.h" // handle list choices
#include "globals.h" // TRUE, FALSE and such things...
#include "events.h"
/***********************************************************************
* Prototypes for internal functions
**********************************************************************/
static void StartApplication(void);
static Boolean MainFormHandleEvent(EventPtr event);
static void EventLoop(void);
/***********************************************************************
*
* FUNCTION: StartApplication
*
* DESCRIPTION: This routine sets up the initial state of the application.
*
* PARAMETERS: None.
*
* RETURNED: Nothing.
*
***********************************************************************/
static void StartApplication(void)
{
FormPtr frm;
FrmGotoForm(1000);
}
/***********************************************************************
*
* FUNCTION: MainFormHandleEvent
*
* DESCRIPTION: Handles processing of events for the "main" form.
*
* PARAMETERS: event - the most recent event.
*
* RETURNED: True if the event is handled, false otherwise.
*
***********************************************************************/
static Boolean MainFormHandleEvent(EventPtr event)
{
Boolean handled = false;
switch (event->eType)
{
//case menuEvent:
// return MainFormDoCommand(eventP->data.menu.itemID);
case frmLoadEvent:
Word formID = event->data.frmLoad.formID;
FormPtr form = FrmInitForm(formID);
FrmSetActiveForm(form);
FrmDrawForm(form);
break;
default:
break;
handled = true;
}
if (event->eType == ctlSelectEvent)
{
if(event->data.ctlEnter.controlID == 1002) //Listitem
chosen
{
wText = handleListChoice();
switch(wText) {
case(0): break; // error
case(101): { FrmGotoForm(1200);
// problem starts here
break;}
}
}
if(event->data.ctlEnter.controlID == 1201) //Button
chosen
{
MemSet(&newEvent, sizeof(EventType), 0);
newEvent.eType = appStopEvent;
EvtAddEventToQueue(&newEvent);
}
return handled;
}
/***********************************************************************
*
* FUNCTION: EventLoop
*
* DESCRIPTION: A simple loop that obtains events from the Event
* Manager and passes them on
to various applications and
* system event handlers before
passing them on to
* FrmHandleEvent for default
processing.
*
* PARAMETERS: None.
*
* RETURNED: Nothing.
*
***********************************************************************/
static void EventLoop(void)
{
EventType event;
Word error;
do
{
// Get the next available event.
EvtGetEvent(&event, evtWaitForever);
// Give the system a chance to handle the event.
if (! SysHandleEvent(&event))
// P2. Give the menu bar a chance to update and
handle the event.
if (! MenuHandleEvent(CurrentMenu, &event, &error))
// Give the application a chance to handle
the event.
if (! MainFormHandleEvent(&event))
// Let the form object provide
default handling of the event.
FrmHandleEvent(FrmGetActiveForm(),
&event);
}
while (event.eType != appStopEvent);
}
/***********************************************************************
*
* FUNCTION: PilotMain
*
* DESCRIPTION: This function is the equivalent of a main() function
* under standard "C". It is
called by the Emulator to begin
* execution of this
application.
*
* PARAMETERS: cmd - command specifying how to launch the
application.
* cmdPBP - parameter block for
the command.
* launchFlags - flags used to
configure the launch.
*
* RETURNED: Any applicable error code.
*
***********************************************************************/
DWord PilotMain(Word cmd, Ptr cmdPBP, Word launchFlags)
{
// Check for a normal launch.
if (cmd == sysAppLaunchCmdNormalLaunch)
{
// Set up initial form.
StartApplication();
// Start up the event loop.
EventLoop();
}
return 0;
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html