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.
PROGRAMMING POWER
Utility routines for programmers
By Alan Jay Weiner

We looked at resources last month, and started looking at forms and controls. This month, I'm going to skip ahead a bit and get some code into your hands. We can return to examine controls next month.

These are some of the routines from my personal library. They make working with buttons and text a bit easier.

Pointers to control objects
Many of the APIs require pointers to various control objects rather than simply the identification number you've assigned them. The GetObjectPtr routine in Listing A (see http://www.component-net.com/pp-extras/utility1.html) takes the ID number and determines the pointer. It assumes that the control is on the currently displayed form.

This routine is straight out of the Palm examples. Many of the following routines use it to reference control objects.

Hiding buttons
Sometimes we want to hide a button. For example, to make sure a particular feature isn't available until some other conditions occur. Or we want to make a button visible because those conditions have been met.

Making a control invisible when the form is displayed is easy. Simply mark it "not usable" when you design the form. Then, when the form is first displayed, the control won't be drawn.

Listing B (see http://www.component-net.com/pp-extras/utility2.html) shows two routines; MakeButtonInvisible hides a button. The other, MakeButtonVisible, unhides it.

Changing a button's text
Listing C (see http://www.component-net.com/pp-extras/utility3.html), ChangeButtonText, changes the text on a button. Use this to make a button mean different things under different circumstances. It's easier to change the text on a single button than to have multiple buttons in the same place.

Centering a line of text on the screen
This final routine, in Listing D (see http://www.component-net.com/pp-extras/utility4.html), centers a line of text. Actually, it's two routines; the first sets the font unless the new font is CURRENT_FONT, or the value -1. While this could be done in-line in the DisplayCentered routine, we'll see it in future text-display routines. It also updates the font value with the original font, so it can later be restored.

The regular fonts are defined in FONT.H; they are stdFont, boldFont, largeFont, symbolFont, symbol11Font, symbol7Font, and ledFont. The Palm III has added a new font called largeBoldFont.

DisplayCentered itself is fairly simple - it optionally changes to a new font, gets the width of the text string, and draws it in the right place.


1  ·  2  ·  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: Apple's latest heartbreaker
David Gewirtz Online: CNN commentary and analysis
DominoPower: Lotusphere 2010: mobility and collaboration
OutlookPower: Running auto-respond rules when Outlook is closed
-- 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