Hello_a.c


The following C program is for the application on the previous slides. Note that this program does not include any UI elements. A well-written application should not include them inside its source code. They must be stored in a resource file.

 Hello_a.c 

#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;
}