#include <PalmOS.h>
#define Form1 1000
#define OK 1003
UInt32 PilotMain( UInt16 cmd, void *cmdPBP, UInt16 launchFlags ) {
short err;
EventType e;
FormType *pfrm;
if ( cmd == sysAppLaunchCmdNormalLaunch ) {
FrmGotoForm( Form1 );
while( 1 ) {
EvtGetEvent( &e, 100 );
if ( SysHandleEvent( &e ) ) continue;
if ( MenuHandleEvent( (void *) 0, &e, &err ) ) continue;
switch ( e.eType ) {
case ctlSelectEvent:
if ( e.data.ctlSelect.controlID == OK )
goto _quit;
break;
case frmLoadEvent:
FrmSetActiveForm( FrmInitForm( e.data.frmLoad.formID ) );
break;
case frmOpenEvent:
pfrm = FrmGetActiveForm( );
FrmDrawForm( pfrm );
break;
case menuEvent:
break;
case appStopEvent:
goto _quit;
break;
default:
if ( FrmGetActiveForm( ) )
FrmHandleEvent( FrmGetActiveForm( ), &e );
break;
}
}
_quit:
FrmCloseAllForms( );
}
return 0;
}
|