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

The following add-ins could not be started MonoDevelop.GnomePlatform

Installing MonoDevelop in OpenSUSE 12.2 from its repository was very easy. When running it for the first time though I got the message: The following add-ins could not be started: The root of the trace shows MonoDevelop.GnomePlatform,2.8 A quick search shows that MonoDevelop depends on libgnomeui . This should have been part of dependencies when installing the application but well.... Below is the screen shot of the error message. References: http://software.1713.n2.nabble.com/MonoDevelop-and-openSUSE-12-1-td7462957.html [2013/04/09] - Same issue observed in OpenSUSE 12.3 and also the same fix. [2014/11/02] - Same issue observed in OpenSUSE 13.3, mondevelop 3.0.6 and the same fix.