Developing Applications for a Handheld PC
Summary: Discusses how to develop applications for business and personal use for Handheld PCs (H/PCs) running the Microsoft® Windows® CE operating system. (11 printed pages) Covers:
Due to the strength of its Microsoft® Windows® CE operating system (OS) and an incredibly productive software package, the Handheld PC (H/PC) has become a viable alternative to traditional, less versatile tools used by the mobile professional. With knowledge of the H/PC's unique opportunities and challenges, plus help from the right development tools, independent software vendors can market profitable applications with minimum design time and effort.
Information appliances are rapidly gaining popularity. More than one million PC companion devices running Windows CE technology have been shipped so far. The H/PC gives an increasing number of mobile professionals the ability to stay connected wherever they are, and provides a growing number of hardware and software vendors the opportunity to create solutions and accessories for business and personal use.
Handheld PCs running Microsoft Windows CE, Handheld PC Edition and Microsoft Windows CE, Handheld PC Professional Edition, are known for their compact size, instant on/off function, long battery life, and synchronization abilities with desktop or laptop computer information. In addition, programming applications for the H/PC and other Windows CE-based devices is simplified by its Microsoft Win32® code base.
H/PCs have a full range of hardware and software components that extend the capabilities of the mobile device category. Creating great applications is a matter of acknowledging the H/PC's characteristics. To address this, the following topics will be discussed in this article:
- New features
Developers can expect these new features in H/PC Pro Edition software.
- Development opportunities
New software development opportunities are created in the H/PC and H/PC Pro Edition platforms.
- Programming considerations
Recognition of some H/PC programming concepts will aid in creating applications.
- Unique APIs
H/PC Pro Edition software exposes new APIs to work with.
With the release of Microsoft Windows CE, Handheld PC Professional Edition version 3.0, more hardware and application features are available, including:
- New hardware options
Full-size video graphics adapter (VGA) and Super VGA screens, touch-type keyboards, universal serial bus (USB), extended battery life, alternative pointing devices (such as touch panel, trackball, and mouse), and additional processors are supported.
- New e-mail client
Microsoft Pocket Outlook e-mail client now supports rich Internet standards IMAP4 and POP3. These standards allow direct e-mail access to Microsoft Exchange and other servers that support Internet standards, hierarchical folders that are synchronized with the server, Internet standard address resolution, conversion of attachments on the device, and the ability to store e-mail attachments on external storage cards.
- New database support
Microsoft Pocket Access and ActiveX® Data Objects for Windows CE (ADOCE) are supported, providing common API access to open database connectivity (ODBC) back ends such as Microsoft SQL Server™.
- Seamless synchronization
Microsoft Windows CE Services 2.2, a desktop application that allows effortless synchronization of data with an H/PC device, now provides configurable remote deployment options for mass installation and easier Windows CE Services setup on the Microsoft Windows NT® operating system.
Figures 1 and 2 show hardware common on H/PC devices.
At the code level, the H/PC Pro Edition platform is virtually identical to the H/PC 2.0 platform except for the Mail Store and Transport APIs. The H/PC Pro Edition software is designed to run on the original H/PC devices as well as the new larger H/PC devices with full-sized screens. This allows applications to reach the widest possible market.
The H/PC provides immediate access to personal information, e-mail, and Microsoft Office data—like Microsoft Word or Microsoft Excel—when people are out of the office. Its longer battery life, instant on/off function, and lightweight design make it ideal for travel, note taking, and time management. Developers can take advantage of these H/PC strengths when designing applications for the H/PC. The following list describes three principal opportunities in application development:
- Porting existing Windows-based desktop applications to the H/PC
- Creating vertical applications for the enterprise market
- Developing applications for mobile professionals
Porting Existing Applications
One way to take advantage of H/PC capabilities is to port existing desktop applications to the H/PC and optimize them for mobile professionals. Many Microsoft Windows 95 applications can be ported to Windows CE with much less effort than would be required to develop them from scratch. Ideas and algorithms from Windows-based applications are easily transferred to the Windows CE environment.
The main requirement is that H/PC applications be designed with the smaller device's characteristics in mind. Memory, power, user-interaction devices, and the broad range of CPU and communications options are all critical concerns when porting. For example, hardware design determines whether the user interacts with the device by typing on a keyboard, giving speech commands, or writing on the screen with a stylus.
Because the Windows CE operating system is designed to use a subset of the Win32 application programming interface (API) from the Windows NT operating system and a similar driver model, recompiling applications for the H/PC is a straightforward process.
Devices running H/PC Pro Edition software are expected to be the first non-PC devices that information services (IS) directors incorporate into the overall information fabric of their business enterprise. With the tools available for H/PC devices, companies will be able to develop applications—based on Microsoft Visual C++®, Microsoft Visual Basic®, and Microsoft Visual J++®—that boost productivity.
Corporations are finding many new uses for H/PCs that are not appropriate for notebook computers. For example, notebooks today can be fairly cumbersome for field use. Users have to turn on the notebook and wait for it to boot up. This process can take more than a minute, hampering situations where data flow is immediate. On an H/PC, users can instantly start collecting or accessing data with the touch of a button.
Applications are needed that address the demands of people who are on the road for long periods of time. This population of mobile professionals has specific requirements, and the H/PC is a great tool for maintaining productivity. The PC companion aspect of the H/PC makes it easy to integrate data into the network that the user has created or modified out of the office or in the field.
The H/PC is expected to have an impact on the education market as well. High school and college students who have a desktop computer can economically achieve mobility by taking an H/PC with them when they're away from their desk.
There is also a great demand for synchronization technologies. Already there is good synchronization between the Handheld PC and the desktop or laptop computer, but what will optimize H/PC devices are new synchronization technologies from H/PCs to the server, and from H/PCs to the network.
Windows CE is an OS based on the Win32 API. Developers familiar with Windows 95 or Windows NT programming already know how to write code for Windows CE and how to use an integrated development environment (IDE).
When designing a Windows CE-based program, developers first determine the configuration of the hardware platform and shell for which they are developing. Because Windows CE is a modular operating system, an original equipment manufacturer (OEM) chooses specific modules and components of Windows CE to configure Windows CE-based devices in many different ways. Within the H/PC device category itself, OEMs may choose to implement different components and hardware options from one another.
The following list highlights important areas to consider when programming an H/PC application:
- Programming environment
- Memory management
- Power management
- User interface design
- Communications and connectivity
Once developers are familiar with their target platform, they must decide what programming environment to use. A variety of programming environments are available for use with Windows CE including Visual C++, Visual Basic, and Visual J++. Windows CE-specific menu items and functionality are added with the following Windows CE toolkits:
- Microsoft Windows CE Toolkit for Visual C++ 6.0
- Microsoft Windows CE Toolkit for Visual Basic 6.0
- Microsoft Windows CE Toolkit for Visual J++ 6.0
- Microsoft Windows CE Platform Builder version 2.12
In addition to choosing a programming environment and toolkit, developers can use other useful programming tools, such as the Microsoft Foundation Classes (MFC) for Windows CE or the Active Template Library (ATL) for Windows CE. ATL is a C++-based ActiveX controller library that simplifies the creation of active controls.
To debug and test development code, the Windows CE IDE provides an emulator for supported platforms like the H/PC.
Low-memory situations are more common on an H/PC than on a desktop computer because the compact size of an H/PC limits the number of memory chips that can be installed. Windows CE circumvents this obstacle by using the WM_HIBERNATE message as its primary mechanism for requesting applications to free memory. When freeing memory is required, the system posts the message to one or more applications, beginning with the application that has been inactive the longest.
Windows CE uses a series of memory thresholds to conserve system resources. The following table shows values for memory thresholds. The values are based on a 1-KB memory page; values for a 4-KB memory page are provided in parentheses.
|Hibernation threshold||128 KB |
|The point at which a system enters a limited-memory state. A system sends a WM_HIBERNATE message when its memory falls below this value.|
|Low-memory threshold||64 KB |
|The minimum available memory that a system must maintain when it is in a low-memory state.|
|Critical-memory threshold||16 KB |
|The minimum available memory that a system must maintain when it is in a critical-memory state.|
Hibernating is vital for applications running on an H/PC. When it receives a WM_HIBERNATE message an application should be programmed to:
- Free any large blocks of memory that were allocated by VirtualAlloc—for example, a cache.
- Free as many Graphics, Windowing, and Events Subsystem (GWES) objects as possible, including windows, bitmaps, and device contexts, because they use large amounts of memory.
- Save the state of the heap in order to restore it later, and then free the entire heap.
When the system brings an application to the foreground, it sends a WM_ACTIVATE message. Applications should be programmed with a WM_ACTIVATE handler that can restore memory resources following hibernation.
The primary function of power management is to increase the battery life of an H/PC. Power management is accomplished by providing accurate estimates of remaining battery life and notifying a user when batteries are nearly depleted. Power management for an H/PC is based on the following assumptions:
- The H/PC is used less than two hours per day in bursts from five minutes to one hour.
- The display is powered 100 percent of the time during use.
- The device runs less than 10 percent of the time during typical use.
- The device uses both main batteries and a backup battery.
- User data is stored in RAM (volatile memory), so provisions for backing up data should be provided.
- PC Cards and other storage devices that draw appreciable power from internal batteries significantly reduce battery life.
An H/PC manages power by allowing the operating system to automatically select one of three operating states, based on user activities and programming activities. These states are dead, suspend, and on.
In the dead state, an H/PC uses no power. It has no batteries, or the batteries have no power. All contents in RAM are lost. The user purchases a device in this state.
In the suspend state, an H/PC uses minimal power to maintain its clock, its applications, and the persistent data stored in RAM. To reduce power requirements, an H/PC removes power from unneeded circuits and devices, such as the keyboard decoder, display, scratch pad memory, and processor. A PC Card storage device driver determines the power that it uses when the device is in the suspend state. The processor might take as long as 100 milliseconds to wake up from this state.
An H/PC switches to the suspend state when the following events occur:
- The user selects the Suspend command.
- The device detects a critical-power condition.
- The activity timer performs a time-out.
An H/PC is in the on state any time the display, keyboard, or touch screen is active. When in the on state, an H/PC can switch between two processor modes: full speed and idle. In full-speed mode, the processor runs at normal operating frequency. In idle mode, the internal processor clock stops, and the processor uses little power. Peripherals and dynamic RAM (DRAM) may be on or off. The processor can enter and exit this state in approximately 10 milliseconds. An H/PC switches to the on state when one of the following events takes place:
- The user presses the On button.
- The user triggers an alarm event.
- The user performs a warm or cold boot.
- The user changes the battery.
In the on state, the default mode is full speed. An H/PC switches from full-speed mode to idle mode when all processes are idle. Switching to idle mode is transparent, both to the user and to most applications, because the system continues to process interrupts, including the time-slice interrupt.
Designing a User Interface for an H/PC
One of the key design goals behind the H/PC is lowering the barriers to entry for new users. The user interface for Windows CE is designed to take advantage of the experienced user's comfort with the Windows 95 interface. Users of Windows CE will find that accessing documents, launching applications, switching among tasks, browsing the file hierarchy in Windows CE, and other common activities are as familiar and easy to perform as they are in Windows 95.
On an H/PC, the desktop forms a visual background for all operations. It provides a familiar interface for accessing documents, launching applications, switching between tasks, browsing the file system, and performing other services. The parts of an H/PC desktop include a work area, a taskbar, and application shortcuts or icons, such as the Recycle Bin and Inbox. Though you cannot change the appearance of the desktop, it is important to understand its specifications so you can design your application's user interface accordingly.
The H/PC shell
The shell is similar to other Microsoft Windows desktops. It contains file, folder, and shortcut icons that a user can position anywhere on the desktop. However, unlike other Windows-based platforms, an H/PC has a virtual border around its desktop to prevent icons from being fully obscured by the screen edge or taskbar. The desktop does not permit a user to position an icon beyond the boundaries defined by the following rectangle coordinates:
(0,0, CX –16, CY –16)
where CX and CY are the width and height of the screen.
A taskbar is used to switch between or minimize open windows and to access global commands and other frequently used objects. The taskbar contains a Start button, window buttons, and a status area. It also contains a Desktop button that provides quick access to the desktop from any application. Because H/PC applications do not have title bars, users identify a running application primarily by the icon and text displayed on its Taskbar button.
By default, the taskbar is the top window in the shell. When fully displayed, the taskbar is 26 pixels high and either 480 or 640 pixels wide, depending on the resolution of the display. In the shell, the taskbar takes on added flexibility. When hidden, the taskbar is 5 pixels tall. When a user hides the taskbar, a notification is sent to all applications that the usable vertical screen is increased by 21 pixels. To reactivate a hidden taskbar, each H/PC touch screen contains a 2.5 mm tap region along all four edges of the display. This, combined with the height of the taskbar, provides a generous tap region for activating the taskbar.
The design of windows is another important element in creating a UI for the H/PC. Windows enable a user to view and interact with data. Consistency in window design is important because it enables users to easily transfer their skills and focus on tasks, rather than learn new conventions.
Primary windows in Windows CE for the H/PC are similar to windows found on desktop-based applications. H/PC applications can use all of the standard menus and controls available in Windows CE.
While all H/PCs conform to a hardware specification standard, some OEMs offer features that extend functionality. These additional features include an expanded LCD screen, 640 x 240 or 640 x 480 pixels in size. The expanded screen allows applications to display up to 80 characters per line at an easily readable character size, using half-height or full-size VGA graphics resolution. This means the font aspect ratio is similar to a desktop computer and eliminates the feeling that the characters are squeezed onto the screen.
Developers can take advantage of the expanded screen size by designing applications capable of displaying a full-width view of documents and images. This minimizes the amount of scrolling needed and makes applications easier to use.
Programming applications for screens that are 640 x 480 pixels does not require that separate code be maintained for H/PCs with screens that are 480 x 240 pixels. Instead, developers can create application windows using default values that indicate full-screen size regardless of the dimension of the screen. You can also position objects using relative, as opposed to absolute, coordinates.
Communications and Connectivity
One of the strengths of the H/PC is its ability to connect to and communicate with other computers and peripherals. The following communication abilities can be integrated with an application:
- Programming a built-in IR port
- Programming with a PC card
- Programming a PC card storage device
- Printing from an H/PC
- Using the transport-neutral encapsulation format (TNEF) API
The Handheld PC Professional Edition software features three new APIs: Mail Store, Transport, and TNEF. The following table shows some of the many APIs that the H/PC Professional Edition software supports.
|Mail Store||Mail API for Inbox that allows the creation and manipulation of e-mail messages.|
|Transport||Mail API that allows sending and receiving of e-mail messages.|
|TNEF||API that converts strings, files, and buffers into a specified format.|
|Windows CE API||Subset of the Win32 APIs that allows interface with the operating system.|
For more information about Microsoft Windows CE, Handheld PC Professional Edition and about developing applications for an H/PC, see the Microsoft SDK for Windows CE, Handheld PC Professional Edition 3.0 documentation and the Windows CE documentation. For more information on how to write ActiveX controls, see the article "How to Write and Use ActiveX Controls for Windows CE."
For the latest information about Windows CE and embedded development tools, see the Microsoft Windows CE developer Web site. Additional white papers are available at the Web site, describing other features of Windows CE.
The information contained in this document represents the current view of Microsoft Corporation on the issues discussed as of the date of publication. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented after the date of publication. This document is for informational purposes only.
This White Paper is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT.
© 1999 Microsoft Corporation. All rights reserved.
Microsoft, ActiveX, Visual Basic, Visual C++, Visual J++, Win32, Windows, and Windows NT are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.
Java is a trademark of Sun Microsystems, Inc.
Other product and company names mentioned herein may be the trademarks of their respective owners.