You are previewing Palm OS Programming, 2nd Edition.
O'Reilly logo
Palm OS Programming, 2nd Edition

Book Description

With more than 16 million PDAs shipped to date, Palm has defined the market for handhelds, having dominated this class of computing devices ever since it began to outpace competitors six years ago. The company's strength is the Palm OS, and developers loyal to this powerful and versatile operating system have created more than 10,000 applications for it. Devices from Handspring, Sony, Symbol, HandEra, Kyocera, and Samsung now use Palm OS, and the number of registered Palm Developers has jumped to 130,000. If you know C or C++, and want to join those who are satisfying the demand for wireless applications, then Palm OS Programming: The Developer's Guide, Second Edition is the book for you. With expanded coverage of the Palm OS--up to and including the latest version, 4.0--this new edition shows intermediate to experienced C programmers how to build a Palm application from the ground up. There is even useful information for beginners. Everything you need to write a Palm OS application is here, from user interface design, to coding a handheld application, to writing an associated desktop conduit. All the major development environments are discussed, including commercial products such as Metroworks CodeWarrior, Java-based environments such as Sun KVM and IBM VisualAge Micro Edition, and the Free Software Foundation's PRC-Tools or GCC. The focus, however, is C programming with CodeWarrior and PRC-Tools. New additions to the second edition include:

  • A tutorial that takes a C programmer through the installation of necessary tools and the creation of a small handheld application.

  • A new chapter on memory, with a comprehensive discussion of the Memory Manager APIs.

  • Greatly expanded discussions of forms, forms objects, and new APIs for the Palm OS.

  • Updated chapters on conduits that reflect the newer Conduit Development Kit.

  • The best-selling first edition of this book is still considered the definitive guide for serious Palm programmers; it's used as the basis of Palm's own developer training materials. Our expanded second edition promises to set the standard for the next generation of Palm developers.

    Table of Contents

    1. Special Upgrade Offer
    2. Preface
      1. What’s New in This Edition
      2. The Source Code Web Site
      3. Whom This Book Is for: C/C++ Programmers
      4. What This Book Is About and How to Read It
      5. How to Read This Book
        1. The Skip-Through Approach
        2. The Cover-to-Cover Approach
        3. The In-Front-of-a-Computer Approach
      6. Conventions Used in This Book
      7. How to Contact Us
      8. Versions of Tools
      9. Who We Need to Thank
    3. I. Overview of the Palm OS
      1. 1. The Palm Solution
        1. How Palm Succeeded
          1. The Magic Formula
          2. Why Palm Succeeded Where So Many Failed
          3. No One Would Make a Good Enough Device
        2. Elements in the Magic Formula
        3. Easy to Carry
        4. Inexpensive
        5. Expandable
          1. Hardware Expandability
          2. Software Expandability
          3. Developing for the Platform
            1. Expandability and the future
            2. Expandability allows users to accomplish different tasks
        6. Effortlessly Connects to a Desktop Computer
          1. What Palm OS Devices Don’t Have and Why
          2. A Keyboard
          3. Text-Recognition Software
          4. A Powerful Processor
        7. Works Great and Is Simple to Use
          1. Battery Life
          2. Common Handheld Tasks Are Simple and Fast
        8. Designing Applications for Palm Devices
          1. Essential Design Elements
            1. Designing for a small screen size
            2. Limiting text input on the handheld
            3. Seamless syncing
            4. Making the application small
            5. Making the application fast
          2. User Interface Guidelines
          3. Elements in a Palm Application
            1. The two-part solution
          4. HotSync Overview
        9. In Conclusion
      2. 2. Technical Overview and Development Environments
        1. Palm OS Overview
          1. Interaction Between an Application and the OS
          2. Memory
          3. Events
          4. Resources
          5. Forms and Controls
          6. Communications
          7. Miscellaneous
        2. Conduit Overview
        3. Handheld Development Environments
          1. CodeWarrior for Palm OS
            1. Developing on the Macintosh
            2. Developing on Windows
          2. PRC-Tools
            1. What’s in PRC-Tools?
            2. Extras
          3. Tools Directly from Palm
        4. Alternative Development Environments
          1. Java
            1. Sun KVM
            2. IBM VisualAge Micro Edition
          2. Jump
          3. Waba
          4. PocketStudio
          5. Pocket C
          6. Assembler SDK (ASDK)
          7. Pocket Smalltalk
        5. High-Level Forms Development
          1. Satellite Forms
          2. AppForge
          3. Pendragon Forms
          4. NS Basic
        6. Handheld Development Recommendations
          1. Developing Using Mac OS
          2. Developing Using Unix
          3. Developing Using Windows
          4. Switching Platforms
            1. Switching development environments
        7. Conduit Development
          1. What Is a Conduit?
          2. Using C/C++
          3. Using Java
        8. In Conclusion
      3. 3. Designing a Solution
        1. User Interface Elements in the Palm OS
          1. Alerts
          2. Forms
          3. Menus, Menu Items, and Menu Bars
            1. Placement
          4. Tables and Lists
            1. Placement
          5. Buttons
            1. Placement
          6. Checkboxes
          7. Command Toolbar
          8. Fields
            1. Placement
          9. Form Bitmap
          10. Gadgets
          11. Graffiti Shift Indicator
            1. Graffiti Shift Indicator placement
          12. Label
          13. Pop-up Trigger
          14. Push Button
            1. Placement
          15. Repeating Button
          16. Scrollbar
            1. Placement
          17. Selector Trigger
          18. Sliders
        2. Designing with a Particular User in Mind
          1. Comparing Date Book, Datebook+, and DateBk4
          2. DateBk4’s Extra Features
            1. Menu icon
            2. Split display and time information
            3. Buttons and their views
            4. Buttons unique to DateBk4
          3. Why the Designs of Date Book, Datebook+, and DateBk4 Differ
            1. Who is the user?
          4. The 80/20 Rule
          5. Date Book: The Most Important Aspects of an Application
            1. Date Book tasks and times
            2. How the 80/20 rule was implemented within Date Book’s design
          6. Datebook+: The Most Important Aspects of an Application
            1. The “p” for P.M.
            2. Extra calendar views
            3. Datebook+ tasks and times
            4. How the 80/20 rule was implemented within Datebook+’s design
          7. DateBk4: The Most Important Aspects of an Application
            1. DateBk4 tasks and times
            2. How the 80/20 rule was implemented within DateBk4’s design
          8. What Should Be Sacrificed?
            1. DateBk4’s pop-up common task list
            2. The split display
            3. Button action and common activity
            4. Abbreviating button names—hitting the screen-size wall
            5. Buttons that don’t look like buttons
            6. Preference dialog boxes
          9. Who Is Your User?
        3. The Well-Designed Form
          1. The To Do List—A Well-Designed Main Form
          2. The Security Application—A Not-So-Well-Designed Form
          3. The Date Book—A Well-Designed Dialog Box
          4. WordSmith—A Well-Designed Dialog Box
          5. The Address Application—A Well-Designed Alert
          6. Bejeweled—A Really Well-Designed Alert
          7. Taking Advantage of the Unique Elements in an Application
            1. Great hinting
            2. Anticipating the user’s needs
            3. Hidden tricks that save time
            4. How to enter an odd appointment time
        4. Other Design Issues
          1. Gotchas from the Desktop
            1. Handling passwords on a handheld
            2. Hey, where’s the Exit button?
          2. Design Issues
        5. How the Sample Applications Are Useful
        6. User Interface of the Sales Application
          1. The Sales Application Customer List
            1. The Customer list
            2. New Customer
          2. Beam All Customers/Send All Customers
          3. The Order Form
            1. Creating items
            2. Another way to add items to an order
            3. Modifying an item in an order
            4. Adding duplicate items to an order
            5. Deleting an item in an order
          4. Changing Customer Information
            1. Customer details
            2. Order details
          5. Deleting the Customer
          6. Beaming the Customer
          7. Edit and Options Menus
        7. Designing the Sales Application
          1. Clarify the Tasks
          2. The Start Screen
          3. Design Trade-offs in the Sample Application
            1. Adding items to an order
            2. Where to put customer information
            3. Creating a new customer
            4. Beaming or sending a list of customers
            5. Deleting a customer
          4. Designing for a Small Screen
          5. Designing the Databases
            1. Customers
            2. Products
            3. Orders
            4. Categories
        8. Designing the Conduit
          1. Processor-Intensive Tasks
          2. Design of the Sales Application Conduit
        9. Design Summary
    4. II. Programming a Palm Application
      1. 4. Tutorial
        1. POSE
          1. Getting and Installing POSE
          2. Emulator Skins
          3. POSE and ROM Images
          4. Retrieving ROM from a Handheld
          5. Creating a New POSE Session
        2. CodeWarrior
          1. What CodeWarrior Includes
          2. Installing 4.0 SDK
            1. Installing additional examples
          3. Installing PilRC Plug-in
          4. Installing OReilly Stationery
          5. CodeWarrior Setup
            1. Launching POSE automatically
            2. Multifile searching
          6. Creating a New Project
          7. Making a PRC
          8. CodeWarrior IDE
            1. The Project window
            2. The Project Settings dialog box
          9. Constructor for Palm OS
        3. PRC-Tools
          1. What PRC-Tools Includes
          2. Installing on Windows
            1. Installing Cygwin shell and utilities
            2. Installing PRC-Tools
            3. Installing the 4.0 SDK
            4. Installing PilRC
          3. Installing on Unix
            1. Installing PRC-Tools
            2. Installing the 4.0 SDK
            3. Installing PilRC
        4. Installing OReilly Sample project
          1. Cloning the Sample Project
          2. Customizing the Output File
          3. A Non-Debug Build
        5. Installing a PRC on the Handheld
          1. Using Windows
          2. Using Mac OS
          3. Using Unix
        6. Installing PRC on POSE
          1. Get Your ROM Image
          2. Installing the Sample Application
        7. Modifying the Sample Application
          1. Change the Application Name
          2. Change the Location of a Button
          3. Register the Creator ID and Set It Appropriately
            1. Changing the creator ID in CodeWarrior
            2. Changing the creator ID in PRC-Tools
          4. Add a Second Button That Beeps
      2. 5. Structure of an Application
        1. Terminology
        2. Palm OS Conventions
          1. Types
          2. Function and Manager Naming Conventions
          3. C Library Conventions
        3. The Palm OS and an Application
          1. The Main Routine: PilotMain
            1. A quick look at PilotMain
          2. The Startup Routine: AppStart
          3. The Closing Routine: AppStop
          4. The Main Event Loop
            1. Handling events with EvtGetEvent
          5. The Event Queue and Application Event Loop
          6. The Four Routines of the Main Event Loop
            1. SysHandleEvent
            2. MenuHandleEvent
            3. AppHandleEvent
            4. FrmDispatchEvent
        4. A Simple Application—OReilly Starter
          1. What the Application Does—Its User Interface
          2. An Overview of the Source Files
          3. The Source File of Main.c
          4. The Form Files of the Application
            1. The EventType data structure
          5. The Utility and Resource Files
          6. Header Files
          7. OReilly Starter Summary
        5. Other Times Your Application Is Called
          1. Launch Codes
          2. Launch Flags
          3. Scenarios
            1. Normal launch
            2. Find when another application is active
            3. Find when your application is active
        6. Examples
          1. Handling a Pen-Down Event
          2. Handling a Graffiti Character
          3. Overriding Hard-Button Behavior
          4. Controlling the Exiting of an Application
        7. What to Remember
      3. 6. Memory Manager
        1. Types of Memory
          1. Read-Only Memory (ROM)
          2. Random-Access Memory (RAM)
            1. Maintaining state
            2. Writing to the RAM memory
            3. Amount of dynamic memory available
        2. Dynamic Memory Allocation
          1. Using Memory Handles
          2. Memory Chunk Size Limitations
          3. Dynamic Memory APIs
            1. Allocation
            2. Locking memory chunks
            3. Memory size information
            4. Heap information
          4. Example
            1. Writing to a block using a structure
            2. Strings in a block
        3. Stack Space
          1. APIs
          2. Example
            1. Setting stack size
            2. Determining stack size
            3. Determining how much stack has been used
            4. Determining the amount of stack remaining
        4. Handling Large Amounts of Data
          1. Relocatable Chunks in the Storage Area
          2. Feature Memory
            1. Allocating feature memory
            2. Retrieving feature memory
            3. Freeing feature memory
          3. File Streaming
        5. Owner IDs
          1. Persistent Memory and Owner IDs
          2. APIs
          3. Owner ID Example
        6. Cards and Local IDs
          1. APIs
        7. Using Memory Effectively
          1. Deciding Whether to Use Pointers or Handles
          2. Check Allocations and Resizes
          3. Our Philosophy on Using Memory Efficiently
        8. MemoryTestAPIs Example
          1. The Code
            1. Handle <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg" class="symbol">&#8594;</span> MemHandleNew MemHandleNew
            2. Handle <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg" class="symbol">&#8594;</span> MemHandleFree MemHandleFree
            3. Handle <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg" class="symbol">&#8594;</span> MemHandleLock MemHandleLock
            4. Handle <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg" class="symbol">&#8594;</span> MemHandleUnlock MemHandleUnlock
            5. Handle <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg" class="symbol">&#8594;</span> Write Write
            6. Handle <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg" class="symbol">&#8594;</span> Read Read
            7. Handle <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg" class="symbol">&#8594;</span> FreeSpace FreeSpace
            8. Handle <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg" class="symbol">&#8594;</span> DmNewHandle DmNewHandle
            9. FeatureMem <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg" class="symbol">&#8594;</span> FtrPtrNew and write FtrPtrNew and write
            10. FeatureMem <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg" class="symbol">&#8594;</span> FtrPtrGet and read FtrPtrGet and read
            11. FeatureMem <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg" class="symbol">&#8594;</span> FtrPtrFree FtrPtrFree
            12. Stack <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg" class="symbol">&#8594;</span> Total Total
            13. Stack <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg" class="symbol">&#8594;</span> Remaining Remaining
            14. Stack <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg" class="symbol">&#8594;</span> Used Used
          2. Testing the Application
        9. What to Remember
      4. 7. Debugging Palm Applications
        1. POSE
          1. POSE Sessions
          2. Installing Applications and PDBs on POSE
          3. Communications
            1. Emulating serial
            2. Emulating TCP/IP
          4. Error Checking with POSE
          5. Logging
          6. Profiling
          7. Remote Scripting
          8. Major Advantages of POSE
          9. Minor Disadvantages of POSE
        2. Graffiti Debugging Shortcuts
        3. Source-Level Debugging
          1. Source-Level Debugging with CodeWarrior
            1. Choosing a target
            2. Debugging commands
            3. Console window
          2. Source-Level Debugging with PRC-Tools
        4. Gremlins
          1. Gremlin ranges
          2. Saved Gremlin state
          3. Gremlins and Gadgets
          4. Using Gremlins Repeatedly
          5. Optimizing Gremlin Debugging
        5. Error Manager
        6. Palm OS Sources
        7. Low-Level Debugging with PalmDebugger
        8. Device Reset
        9. Using Simulator on Mac OS
        10. Release/Debug Targets
          1. Releasing and debugging builds in CodeWarrior
          2. Releasing and debugging builds in PRC-Tools
      5. 8. Resources and Forms
        1. Resources
          1. Creating Resources in PilRC
            1. The pretty points of PilRC
            2. PilRC example
            3. Aligning form objects with PilRC
            4. Using constants for your resources
          2. Reading Resources
          3. Writing Resources
        2. Form Characteristics
        3. Form Events
        4. Form-Level APIs
        5. Modeless Forms
        6. Alerts
          1. Customizing an Alert
          2. Alert APIs
          3. Alert Example
          4. Tips on Creating Alerts
        7. Modal Dialog Boxes
          1. Dialog Box APIs
          2. Flexible Modal Dialog Boxes
          3. A Tip for Modal Forms
          4. Modal Form Sizes
          5. Help for Modal Forms
        8. Forms in the Sales Application
          1. Alerts
            1. Defining the alerts
            2. Calling FrmAlert in our application
            3. Calling FrmCustomAlert
          2. Delete Customer
      6. 9. Form Objects
        1. Form Object Characteristics
          1. What We Talk About Next
        2. Form Object Events
          1. Events Generated by a Successful Tap
          2. Events Generated by Maintaining a Press
          3. Events Generated by the Start of a Tap
          4. Events Generated by the End of an Unsuccessful Tap
        3. Form Object APIs
          1. Converting Between IDs and Indexes
          2. Hiding and Showing Objects
          3. Form Object Pointers
          4. Error Checking
        4. Types of Form Objects
          1. Labels
            1. Example
          2. Bitmaps
            1. Application icons
          3. Graffiti Shift Indicator
          4. Lists
            1. A sample that displays a specific list item
            2. Custom versus noncustom lists
            3. Creating a runtime list with LstSetListChoices
            4. Creating a runtime list with LstSetDrawFunction
          5. Controls
            1. Control APIs
            2. Using graphical labels rather than text labels for controls
            3. Buttons
            4. Push buttons
            5. Checkboxes
            6. Selector triggers
            7. Repeating buttons
            8. Pop-up trigger objects
            9. Sliders
          6. Gadgets
            1. Gadget APIs
            2. Gadget responsibilities
            3. A simple gadget
            4. A sample using extended gadgets
            5. Gadget tip
          7. Fields
            1. Setting text in a field
            2. Field utility routines
            3. Modifying text in a field
            4. Getting text from a field
            5. Setting the focus of a field
            6. Field gotchas
          8. Scrollbars
            1. Scrollbar coding requirements
            2. Updating the scrollbar based on the insertion point
            3. Updating the scrollbar when the number of lines changes
            4. Updating the display when the scrollbar moves
            5. Updating the display when the scroll buttons are used
            6. Scrolling a full page
          9. Tables
            1. Display-only data types
            2. Edit and display data types
            3. Display-only data types
            4. Editable data types
            5. Initializing tables
            6. Resource
            7. Initialization of the records in the database
            8. Initialization of the simple table sample
            9. Column 0: handling numbers
            10. Column 1: a checkbox
            11. Column 2: a label
            12. Column 3: a date
            13. Column 4: a pop-up trigger
            14. Column 5: handling text
            15. Column 6: handling custom content
            16. Displaying the columns
            17. Custom load routines
            18. Custom save routine
            19. Releasing the records
            20. Custom draw routine
            21. Handling a table event
        5. Sales Application Forms and Form Objects
          1. Edit Customer
            1. Creating the Customer Information form
            2. Event handler for the form
            3. Initialization code
            4. Utility routines
          2. Item Details
            1. Item details display code
            2. Event handler code
            3. Handling the pop-up trigger and list
          3. Customers Form
            1. Initialization routines
            2. Event handler
          4. Order Form
            1. Initialization routine
            2. Global variables
            3. Setting pop-up triggers and fields
            4. Hiding and showing objects
            5. Initializing the data
            6. Handling keystrokes
            7. Handling events
            8. Scrolling
            9. Deselecting a row
          5. Switching Forms
      7. 10. Databases
        1. Overview of Databases and Records
          1. Record Databases
          2. Resource Databases
          3. Write-Protected Memory
          4. Palm 3.0 OS Heap Changes
          5. Where Databases Are Stored
          6. How Records Are Stored Versus How They Are Referenced
        2. Opening, Creating, and Closing Databases
          1. Opening a Database
            1. Opening by type and creator
            2. Opening by name
          2. Closing a Database
          3. Creating a Database
            1. Create your database in your AppStart routine
            2. Creating a database from an image
          4. Creating the Application Info Block in a Database
          5. Iterating Through Databases
        3. Working with Records
          1. Reading from a Record
          2. Modifying a Record
          3. Creating a New Record
            1. Adding at the beginning of the database
            2. Adding at the end of the database
          4. Deleting a Record
            1. Deleting a brand new record
            2. Deleting a record that exists also on the desktop
            3. Deleting a record that the user wants archived
            4. Where to put archived and deleted records
          5. Handling Secret Records
          6. Determining the Number of Records
          7. Iterating Through the Records in a Database
          8. Finding a Record
            1. Finding a record given a unique ID
          9. Sorted Databases
            1. Comparison function
            2. Adding in sort order
            3. Finding a record given a key
            4. Sorting the records in a database
            5. Sorting after a sync
            6. Modifying a record in a sorted database
          10. Dealing with Large Records
            1. File streaming
            2. Multiple chunks in a separate database
          11. Editing a Record in Place
            1. Initialize the field with the handle
            2. Cleanup once the editing is finished
        4. Examining Databases in the Sales Sample
          1. Defining the Sales Databases
          2. Reading and Writing the Customer
          3. Reading and Writing Products
          4. Working with Orders
          5. Creating or Opening the Databases
          6. Closing the Sales Databases
          7. Initializing the Sales Databases
            1. Initializing the customer database
            2. Initializing the product database
            3. Comparison routine for sorting
            4. Initializing the Orders database
          8. The Customers Form
          9. Editing Customers
          10. The Order Form
            1. Editing an item
            2. Deleting an item
            3. Adding a new item
            4. Finishing an Order record
          11. The Item Form
        5. Summary
      8. 11. Menus
        1. Menu User Interface
          1. Arranging Menus
          2. Standard Menu Items
            1. Edit menu
            2. About application
          3. Applications Can Have Multiple Sets of Menus
          4. Applications Can Have Dynamic Menus
          5. Common Menu Shortcuts
            1. Accessing the Command toolbar with a menu shortcut
        2. Menu Resources
          1. Associating Menu Bars with Forms
        3. Application Code for Menus
          1. MenuHandleEvent
          2. MyFormHandleEvent
          3. Handling Items in the Edit Menu
            1. Handling Cut and Paste correctly
          4. The About Menu
          5. Menu Erase Status
          6. Handling Unusable Menu Items
            1. A good time to remove a menu item
            2. Adding a menu item dynamically
            3. Using a separate menu bar
          7. Adding to the Command Bar
        4. Adding Menus to the Sample Application
          1. The Menu Bars
          2. Menu Definitions
          3. Handling Common Menus
          4. The Customers Form
          5. The Order Form
        5. Summary
      9. 12. Extras
        1. Find
          1. Overview of Find
            1. The objectives of Find
            2. Find minimizes memory use
          2. A Walkthrough of Finding Items
            1. The application’s response to a Find request
            2. Handling a Find request with multiple databases
            3. Navigating to a found item
            4. Displaying a found item from a running application
            5. Displaying a found item from a closed application
          3. Find in the Sales Application
            1. Handling the Find request
            2. Searching for matching strings
            3. Displaying the found item
        2. Exchange
          1. The Exchange Manager
          2. Overview of Sending
          3. A Programming Walkthrough of Sending and Receiving
          4. Implementing Exchange
            1. Optimization tips
            2. Debugging tips
            3. General tips
          5. Step-by-Step Implementation Checklist
            1. Determine data interchange format
            2. Add user interface
            3. Send an entry
            4. Receive an entry
            5. Display received item
            6. Send an entire category
            7. Receive an entire category
            8. Test all possibilities
          6. Sales Application
            1. Sending a single customer
            2. Receiving a record
            3. Sending all customers
            4. Receiving all customers
      10. 13. Communications
        1. Serial Communications
          1. Serial APIs
          2. Connection Manager
          3. Tips for Using the Serial Manager
          4. Sample Serial Application
            1. Features of the sample application
            2. The GPS device
            3. The NMEA protocol
            4. Opening the serial port
            5. Closing the serial port
            6. Routines that work with the old and new Serial Managers
            7. Allowing the user to choose a port
            8. Opening the port
            9. The Main form
            10. Setting the receive buffer to hold data
            11. The event loop
            12. The event handler
            13. Updating the display with new GPS data
            14. Alerting the user if GPS hasn’t been heard from lately
            15. Reading the GPS data
            16. Updating the display
          5. Sample Asynchronous Receive
            1. The application’s resource and global variable
            2. The wakeup handler
            3. The event handler
            4. Reading the data
        2. TCP/IP Communications
          1. Network API
            1. Berkeley Sockets API
            2. Palm OS NetLib API
            3. Net library and the Berkeley Sockets API
          2. Tips for Using TCP/IP
          3. Sample Network Application
            1. Creating the sample application on Linux
            2. The Linux main program
            3. Linux include files and global definitions
            4. Sending the mail
            5. Connecting to the server
            6. Getting a port
            7. Reading data character by character
            8. Sending data character by character
            9. Testing the Linux application
            10. Porting the Linux application to Palm OS
    5. III. Designing Conduits
      1. 14. Getting Started with Conduits
        1. Overview of Conduits
          1. What Does a Conduit Do?
          2. Conduit Development on Windows
            1. CDK versions and Palm Desktop
            2. Using C++
            3. Using Java
            4. Using Visual Basic or other COM-creating environments
          3. Conduit Development on Macintosh
          4. Required Elements in a Minimal Conduit
        2. Using the Backup Conduit
          1. Applications That Might Use the Backup Conduit
          2. Using System Prefs Instead
          3. Setting the Backup Bit for a Database
          4. Set the Backup Bit for Every Application
        3. Registering and Unregistering
          1. The Old, Ugly Way
          2. The New, Sleek Way
          3. Conduit Entry Information Needed to Register
            1. Required conduit entries
            2. Optional entries
            3. JSync Suite entries
            4. COM Sync Suite entries
          4. Registering and Unregistering Manually Using CondCfg
        4. Using Desktop APIs
          1. Registering/Unregistering Conduit Manager APIs
            1. Installing the conduit
            2. ConduitInstall.exe
            3. Automatically uninstalling a conduit
          2. The HotSync APIs
          3. Retrieving Users and Installing Application APIs
          4. A Complicated Wrinkle—Finding the Correct DLL
            1. The solution to finding the correct DLL
            2. Implementing the solution
            3. The elements in our solution
            4. Modifying the application
            5. The code for PalmDLLShim
          5. Important Issues for Creating an Installer
            1. What the installer needs to do
            2. How the installer will work
        5. Conduit Entry Points
          1. Required Entry Points
          2. Optional Entry Points
            1. Optional File Linking entry points
        6. The HotSync Log
          1. long LogAddEntry(LPCTSTR logString, Activity act, BOOL timestamp)
          2. long LogAddFormattedEntry(Activity act, BOOL timestamp,const char* dataString, ...)
        7. When the HotSync Button Is Pressed
        8. Using Conduit Inspector to Verify Your Conduit
          1. Running the Conduit Inspector Manually
          2. Running the Conduit Inspector from the HotSync Application
        9. Syncing from POSE
          1. If You Are Using Palm OS 3.3 or Later
          2. If You Are Using Palm OS 3.0 to 3.2
        10. Creating a Minimal Sales Conduit
          1. Code for the Sales Conduit
          2. Registering the Conduit
          3. Source-Level Debugging
          4. Testing
            1. Proving that CfgConduit works
            2. Seeing the conduit in the HotSync log
            3. Setting the conduit to Do nothing
      2. 15. Moving Data to and from the Handheld with a Conduit
        1. Conduit Requirements
        2. Where to Store Data
        3. Creating, Opening, and Closing Databases
          1. Creating a Database
          2. Opening a Database
          3. Closing the Database
        4. Moving Data to the Handheld
          1. Deleting Existing Records
          2. Writing Records
          3. Writing the AppInfo Block
        5. Moving Data to the Desktop
          1. Finding the Number of Records
          2. Reading Records
            1. Iterating through each record, stopping only for altered ones
            2. Looking up exact records via unique record ID
            3. Iterating through the records of a database from beginning to end
            4. The CRawRecordInfo class
          3. Reading the AppInfo Block
          4. Deleted/Archived Records
            1. Archiving records
            2. Deleting records
        6. Keeping the HotSync Progress Dialog Box Alive
        7. When the HotSync Button Is Pressed
        8. Portability Issues
          1. Byte Ordering
          2. Structure Packing
        9. The Sales Conduit
          1. Format Used to Store Data on the Desktop
          2. Modifying OpenConduit
          3. General Code
            1. Database defines
            2. Globals
            3. Data structures
          4. Moving Data to the Handheld
            1. Moving customers to the handheld
            2. Moving products to the handheld
          5. Moving Data to the Desktop
            1. Moving orders to the desktop
            2. Moving customers to the desktop
      3. 16. Two-Way Syncing
        1. The Logic of Syncing
          1. Thorny Comparisons—Changes to the Same Records on Both Platforms
            1. The rule—first, do no harm
            2. A record is deleted on one database and modified on the other
            3. A record is archived on one database and changed on the other
            4. A record is archived on one database and deleted on the other
            5. A record is changed on one database and changed differently on the other
            6. A record is changed on one database and changed identically on the other
          2. Fast Sync
            1. Examine the handheld data
            2. Examine the local desktop data
            3. Dispose of the old data
            4. Save a backup file
          3. Slow Sync
            1. Comparing the backup record to the current records
        2. MFC Conduit Framework
        3. Generic Conduit Framework
          1. Advantages of Using Generic Conduit
        4. Generic Conduit Classes
          1. CPalmRecord
          2. CPCategory
          3. CPCategoryMgr
          4. CPDbBaseMgr
          5. CHHMgr
          6. CPcMgr
          7. CPLogging
          8. CSynchronizer
        5. Using the Wizard to Create a Minimal Generic Conduit
          1. Registering the Conduit
          2. What the Conduit Does
        6. Custom File Formats
          1. The StoreDB Routine
          2. The RetrieveDB Routine
        7. Handling Categories
        8. Sales Conduit Based on Generic Conduit
          1. CSalesGenPCMgr
            1. CSalesGenPCMgr constructor
            2. CSalesGenPCMgr destructor
            3. StoreDB function
            4. Retrieving a database
            5. Reading customer information
            6. Customizing resources
            7. Registering the conduit
            8. Testing the conduit
          2. CSalesGenSynchronizer
            1. Class definition
            2. Modifying Perform to add uploading and downloading products and orders
          3. Testing the Conduit
    6. IV. Appendixes
      1. A. Where to Go from Here
        1. Palm Programming Book Web Site
        2. The Official Palm Developer Site
          1. Getting Your Application Creator ID
          2. Knowledge Base
          3. Resource Pavilion
          4. Palm-Powered Compatible Solution
        3. Palm Programming Mailing Lists
          1. Palm OS Developer Exchange
        4. Third-Party Palm Programming Resources
          1. Newsgroups
          2. Palm Programming FAQ
      2. B. Sales Source Code
        1. Source Code
          1. Customer.c
          2. Customers.c
          3. Data.c
          4. Exchange.c
          5. Item.c
          6. Order.c
          7. Sales.c
          8. Utils.c
        2. Headers
          1. Common.h
          2. Customer.h
          3. Customers.h
          4. CWDebugDefines.h
          5. Data.h
          6. Exchange.h
          7. Item.h
          8. Order.h
          9. SalesRsc.h
          10. Utils.h
        3. Resources
          1. Sales.rcp
        4. PRC-Tools Build Files
          1. Makefile
          2. Sales.def
      3. C. PilRC Manual
        1. Usage
          1. Examples
        2. Understanding the Manual
          1. Syntax
          2. Types
          3. Comments
          4. Include Files
        3. Resource Language Reference
        4. FORM (tFRM)
        5. MENU (MBAR)
        6. ALERT (Talt)
        7. VERSION
        8. STRING (tSTR)
        9. STRINGTABLE (tSTL)
        10. CATEGORIES (tAIS)
        11. APPLICATIONICONNAME (tAIN)
        12. APPLICATION (APPL)
        13. LAUNCHERCATEGORY (taic)
        14. ICON (tAIB)
        15. SMALLICON (tAIB)
        16. BITMAP (Tbmp) (tbsb)
        17. TRAP (TRAP)
        18. FONT (NFNT)
        19. FONTINDEX
        20. HEX
        21. DATA
        22. INTEGER (tint)
        23. BYTELIST (BLST)
        24. WORDLIST (wrdl)
        25. LONGWORDLIST (DLST)
        26. PALETTETABLE (tclt)
        27. FEATURE (tfea)
        28. GRAFFITIINPUTAREA (silk)
        29. COUNTRYLOCALISATION (cnty)
        30. KEYBOARD (tkbd)
        31. MIDI (MIDI)
        32. International Support
          1. Example
          2. TRANSLATION
            1. Notes:
            2. Example
        33. Known Bugs
    7. Index
    8. About the Authors
    9. Colophon
    10. Special Upgrade Offer
    11. Copyright