Search PalmPower's 487 Palm-related article archive 
Home
EasyPrint
News details Click here for the RSS feed's XML code. This is not a browser URL.
Articles-only Click here for the RSS feed's XML code. This is not a browser URL.
Hello World! (continued)

If SysHandleEvent() didn't handle the event, it's passed to MenuHandleEvent(). Again a system API, it handles such as tapping on the menu key or selecting a menu item.

If still not handled, the event loop passes the event to ApplicationHandleEvent(). This is the first user-defined event handler. Typically it checks for only "load form" events; setting a form event handler for the specified form. Usually each form has its own event handler.

Finally, if the event still hasn't been handled, it is given to FrmDispatchEvent(). Another OS API, it sends the event to the appropriate event handler for the active form. That's the one set when ApplicationHandleEvent() handles the "load form" event. The form-event-handler watches for any events where we should actually do work. For example, our main-form-specific handler handles the button-press event that causes us to display "hello again!"

It's a bit convoluted. Just remember that the event loop gets an event, passes it to several event handlers, and one of them handles the event. The form-specific handler handles the events that make us do real work.

Function 5: ApplicationHandleEvent()
Our ApplicationHandleEvent() indeed does handle just one event: frmLoadEvent, a message from the OS indicating we're loading a new form. Getting the form ID number from the event structure, we tell Palm OS to initialize and activate that form. Then, we tell the OS which event handler to use for that form's events. Again, that's the handler called when the event loop passes an event to FrmDispatchEvent().

Function 6: MainFormHandleEvent()
This is where we watch for events and do real work. Ours handles three types of events:

  • frmOpenEvent tells us the form is active - we can now draw it. So we do; we get a pointer to the form, and tell the OS to draw that form on the display. Palm OS draws the form and its controls.

  • ctlSelectEvent tells us a control has been "selected" - in our case; the "hello again" button was pushed. We check the button ID number (given in the event structure); if it's the "hello again" button, we draw "hello again" on the form. WinDrawChars() puts the text onto the display (onto the current form); most of the line is to calculate where to place it so it's centered.

  • menuEvent tells us that a menu item was selected. Usually what we do depends on the menu item's ID number. We're told that in the event structure. Since we know there's only one menu option ("about") we take a shortcut. With only one choice, we just do the work. First, we tell the menu to go away, then switch to our AboutForm (by its form ID number). We treat it here as a special dialog; we'll cover this in more detail in another article. In short, it displays the AboutForm and when the user presses the AboutForm's "ok" button it closes that form. The key is that nothing can happen except pressing a button to close the form. That's why I didn't do the whole "hello world" application as a special dialog.


« Previous  ·  1  ·  2  ·  3  ·  4  ·  5  ·  6  ·  Next »
Other articles you might like
Home > Phones and PDAs > Palm and Treo > Programming (24 articles)
   How PDA software is born
   Program with Simplicity
   Kinectivity 2.0 brings enterprise application developers new tools
Get Weekly Email Updates
Subscribe to our regular weekly email newsletter. It's packed with tips, reviews, deep analysis, and the latest news.
 
Other PalmPower Articles
Palm gets up to date with new Tungsten family of handhelds
Create handwritten email with riteMail
Presenter-to-Go puts PowerPoint presentations on your Palm OS handheld
Looking for the cutting edge
Gain remote access to databases and PLCs
PalmSource Open House showcases what's new in the Palm community
Analysis: handheld market share
More from the ZATZ journals
Computing Unplugged: The iPad defenders have spoken
David Gewirtz Online: CNN commentary and analysis
DominoPower: Application development, William Shatner, and the origin of the universe
OutlookPower: More about disappearing text
-- Advertisement --

ONLINE GROUP CALENDAR - FOR UP TO 100 OF YOUR CLOSEST FRIENDS
Stay organized and in control with 24/7 access to all of your important events, projects and files --whether you're at work, at home or on the road.

You can share your calendar, projects and files so everyone in your office is up to date. Plus, search your entire group to find times when everyone is available to meet, manage company resources and much more.

Organize your entire team for as low as $9.95 per year (and yes, that's where the decimal place is supposed to be!)

Tap here to get started right away.

ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
Copyright © 1998-2010, ZATZ Publishing. All rights reserved worldwide.
Editor's Login