Programs for the PDA

   The code below is the setup for a basic Hello World application for a PDA.  Code Warrior has specific directories that need to be modified in order to create PDA programs.  These are found in the OReilly Starter file. This file can be downloaded at this page.  Starter File Once this is added to Code Warrior the following changes need to be made to each directory which is underlined and in bold.  Putting this code into the directories is not enough.  Please refer to the Programming Tutorial in order to understand the programming in detail.

ResourceDefines.h

 #define RomIncompatibleAlert           1001

 #define MainForm                  2000        

#define MainHelloButton         2001

#define MainWorldButton       2002

#define MainClearButton         2003

  

Resources.rcp

 #include "ResourceDefines.h"

 APPLICATIONICONNAME 1000 "Starter"

 ALERT ID RomIncompatibleAlert

CONFIRMATION

BEGIN

  TITLE "System Incompatible"

MESSAGE "System Version 3.0 or greater " \

    "is required to run this application."

 BUTTONS "OK"

<>END <>  

FORM ID MainForm AT (0 0 160 160)

USABLE

BEGIN

  TITLE "Hello Button"

<> BUTTON "Hello" ID MainHelloButton AT (40 100 AUTO AUTO)

  BUTTON "World" ID MainWorldButton AT

    (PrevLeft PrevBottom + 5 AUTO AUTO)

  BUTTON "Clear" ID MainClearButton AT (PrevLeft PrevBottom + 5 AUTO AUTO)

END

 

 

MainForm.c

 /*

 Copyright (c) 2000-2001, Neil Rhodes and Julie McKeehan

  neil@pobox.com

 All rights reserved.

 From the book "Palm Programming, the Developer's Guide, 2nd edition"

by O'Reilly.

 Permission granted to use this file however you see fit.

*/

 

define DO_NOT_ALLOW_ACCESS_TO_INTERNALS_OF_STRUCTS

#include <BuildDefines.h>

#ifdef DEBUG_BUILD

#define ERROR_CHECK_LEVEL ERROR_CHECK_FULL

#endif

#include <PalmOS.h>

#include "ResourceDefines.h"

#include "MainForm.h"

 

 static

void MainFormInit(FormPtr form)

{

#pragma unused(form)

  / warning-- don't do any drawing in this routine.

  // Also, don't call FrmSetFocus from here (it must be called *after*

  // FrmDrawForm)

}

 static

void MainFormDeinit(FormPtr form)

{

#pragma unused(form)

}

 

 Boolean MainFormHandleEvent(EventPtr event)

 Boolean handled = false;

  formPtr form;

  switch (event->eType)

 {

 case frmOpenEvent:

    form = FrmGetActiveForm();

    MainFormInit(form);

    FrmDrawForm(form);

    // here's where you'd add a call to FrmSetFocus

    handled = true;

    break;

     

     

  case ctlSelectEvent:

  switch (event->data.ctlSelect.controlID) {

   case MainHelloButton:

       WinDrawChars("Hello    ", 8, 30, 60);

      handled = true;

      break;

       

    case MainWorldButton:

      WinDrawChars("World", 5, 30, 60);

      handled = true;

      break;

   

    case MainClearButton:

      WinDrawChars("               ", 15, 30, 60);

      handled= true;

      break;

    }

    break;

 

  case frmCloseEvent:

    MainFormDeinit(FrmGetActiveForm());

    handled = false;

    break;

 

  default:

    break;

 

return handled;

}

HOME