Email:   


Home
In This Issue
Email a Friend
EasyPrint
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.





[ Next ]

-- 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.

-- Advertisement --

SECURE YOUR SITE WITH AN IRONCLAD SSL CERTIFICATE
An IronClad SSL Certificate helps you build an impenetrable fortress around your customer's credit card information. IronClad SSL Certificates are:

  • Fully validated
  • Up to 256-bit encryption
  • Up to 10 years validity
  • Stringent authentication
  • Around-the-clock customer support

Build trust. Protect your customers. Grow your online business.

Tap here now and be IronClad with SSL tonight.

Copyright © 1998-2008, ZATZ Publishing. All rights reserved worldwide.