Skip to main content

Creating a dynamic form in Palm OS

Code below shows how to create a dynamic form for Palm OS 3.0 or greater. See this link of the entire project created using Palm OS Development Suite.

/****************************************************************************** * Application Name : DynamicUI.prc * Purpose : Demonstrate how to create a dynamic UI * Programmed by : Techno Scavenger *****************************************************************************/ #include <PalmOS.h> /*********************************************************************** * * Internal Constants * ***********************************************************************/ #define appFileCreator 'ewa8' #define appVersionNum 0x01 #define appPrefID 0x00 #define appPrefVersionNum 0x01 /*********************************************************************** * * Application constants * ***********************************************************************/ #define MainForm 1000 /*********************************************************************** * FUNCTION: MainFormHandleEvent * DESCRIPTION: This routine is the event handler for the * "MainForm" of this application. * PARAMETERS: pEvent - 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(EventType* pEvent) { Boolean handled = false; FormType* pForm; switch (pEvent->eType) { case frmOpenEvent: pForm = FrmGetActiveForm(); FrmDrawForm(pForm); 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(EventType* pEvent) { UInt16 formId; FormType* pForm; Boolean handled = false; if (pEvent->eType == frmLoadEvent) { formId = pEvent->data.frmLoad.formID; // pForm = FrmInitForm(formId); pForm = FrmGetFormPtr(MainForm); FrmSetActiveForm(pForm); // 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(pForm, MainFormHandleEvent); break; default: break; } handled = true; } return handled; } /*********************************************************************** * FUNCTION: AppEventLoop * DESCRIPTION: This routine is the event loop for the application. * PARAMETERS: nothing * RETURNED: nothing * REVISION HISTORY: ***********************************************************************/ static void AppEventLoop(void) { Err error; EventType event; do { EvtGetEvent(&event, evtWaitForever); if (SysHandleEvent(&event)) continue; if (MenuHandleEvent(0, &event, &error)) continue; if (AppHandleEvent(&event)) continue; FrmDispatchEvent(&event); } while (event.eType != appStopEvent); } /*********************************************************************** * FUNCTION: AppStart * DESCRIPTION: Get the current application's preferences. * PARAMETERS: nothing * RETURNED: Err value errNone if nothing went wrong * REVISION HISTORY: ***********************************************************************/ static Err AppStart(void) { // FrmGotoForm(MainForm); static Char strTitle[13] = "Dynamic Form"; FormType* pMainForm; pMainForm = FrmNewForm( MainForm, strTitle, 0, 0, 160, 160, false, 0, 0, 0); FrmGotoForm(MainForm); return errNone; } /*********************************************************************** * FUNCTION: AppStop * DESCRIPTION: Save the current state of the application. * PARAMETERS: nothing * RETURNED: nothing * REVISION HISTORY: ***********************************************************************/ static void AppStop(void) { // Close all the open forms. FrmCloseAllForms(); } /*********************************************************************** * 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: ***********************************************************************/ UInt32 PilotMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) { Err error = errNone; switch (cmd) { case sysAppLaunchCmdNormalLaunch: if ((error = AppStart()) == 0) { AppEventLoop(); AppStop(); } break; default: break; } return error; }

Comments

Popular posts from this blog

Error! Could not locate dkms.conf file install VirtualBox 4.1.8 on Ubuntu 11.10

Tried to update my Ubuntu host today and it did pickup that new version of VirtualBox is available (4.1.8). All other packages installed properly except that VirtualBox installation was complaining about missing dkms.conf file, see error message below. $: sudo /etc/init.d/vboxdrv setup * Stopping VirtualBox kernel modules [ OK ] * Uninstalling old VirtualBox DKMS kernel modules Error! Could not locate dkms.conf file. File: does not exist. [ OK ] * Trying to register the VirtualBox kernel modules using DKMS [ OK ] * Starting VirtualBox kernel modules [ OK ] Though it looks like installation was fine but I am concerned about its effects to VirtualBox functionality. To fix this, do: $: cd /var/lib/dkms/vboxhost $: sudo rm -r 4.1.4 $: sudo /etc/init.d/vboxdrv setup Of course you have to re...

UnrealEngine GenerateProjectFiles.bat error - could be due to missing RPCUtility.exe

Tried to run  GenerateProjectFiles.bat to build Unreal Engine from source ( link ),  but got error like below: C:\>Users\x\UnrealEngine>GenerateProjectFiles.bat Setting up Unreal Engine 4 project files... GenerateProjectFiles ERROR: It looks like you're missing some files that are required in order to generate projects.  Please check that you've downloaded and unpacked the engine source code, binaries, content and third-party dependencies before running this script. To fix, run setup.bat like: C:\Users\x\prj\UnrealEngine>setup.bat Note that you have to say no to the prompt Would you like to overwrite your changes (y/n)? .