In most respects, programming a navigation control is identical to programming any other Windows input device; that is, your application captures messages and acts on them in the WndProc function. However, Windows CE for a Palm-size PC implements a specific messaging style that you need to be aware of in order to write applications efficiently.
Navigation controls communicate with the Windows CE operating system by sending messages. An OEM provides the driver that links each navigation control with WM_KEYUP and WM_KEYDOWN messages individually or in a series. Each message has a virtual key message in its wParam parameter. A user activates the driver when he or she presses a navigation control. The driver then sends the window messages to the Palm-size PC shell. The shell passes the messages to the current application. The following table shows a sample message map. The messages for each operation on a control are sent in the order shown. This sample may not be consistent with the driver installed on your target device.
Operation on control |
Messages |
wParam |
Press Action | WM_KEYDOWN | VK_F23 |
Release Action | WM_KEYUP | VK_F23 |
WM_KEYDOWN | VK_RETURN | |
WM_KEYUP | VK_RETURN | |
Press Exit | WM_KEYDOWN | VK_F24 |
Release Exit | WM_KEYUP | VK_F24 |
WM_KEYDOWN | VK_ESCAPE | |
WM_KEYUP | VK_ESCAPE | |
Press ArrowUp | WM_KEYDOWN | VK_UP |
Hold down ArrowUp | WM_KEYDOWN | VK_PRIOR |
WM_KEYUP | VK_PRIOR | |
Release ArrowUp | WM_KEYUP | VK_UP |
Press ArrowDown | WM_KEYDOWN | VK_DOWN |
Hold down ArrowDown | WM_KEYDOWN | VK_NEXT |
WM_KEYUP | VK_NEXT | |
Release ArrowDown | WM_KEYUP | VK_DOWN |
Press Prog2 | WM_KEYDOWN | VK_LWIN |
WM_KEYDOWN | 0xC2 | |
Release Prog1 | WM_KEYUP | VK_LWIN |
WM_KEYUP | 0xC1 | |
Press Prog2 | WM_KEYDOWN | VK_LWIN |
WM_KEYDOWN | 0xC2 | |
Release Prog2 | WM_KEYUP | VK_LWIN |
WM_KEYUP | 0xC2 | |
Press Prog3 | WM_KEYDOWN | VK_LWIN |
WM_KEYDOWN | 0xC3 | |
Release Prog3 | WM_KEYUP | VK_LWIN |
WM_KEYUP | 0xC3 | |
Press Prog4 | WM_KEYDOWN | VK_LWIN |
WM_KEYDOWN | 0xC4 | |
Release Prog4 | WM_KEYUP | VK_LWIN |
WM_KEYUP | 0xC4 |
Keep the following information in mind when programming an application with a message map similar to the previous sample:
Name |
Example |
Contains |
Name | "Calendar Button" | Name of the application |
Icon | "\windows\fud.dll, -23" | Location of the application’s icon for the Start menu |
Flags | 0x0001 | Flags representing special attributes of the control |
ResetCmd | ""calendar.exe" -score" | Default command line |
On a Palm-size PC, a user can access the Button Properties dialog to associate a program control with any application that is accessible through the Start menu or its Program submenu. When the user changes a control, the operating system sends out a WM_WININICHANGE message to all active applications. This message informs the applications that the hardware control map has been changed.
The Palm-size PC shell adds a layer of indirection between the hardware driver and your application, which may slow your application down. To increase the speed of your application, you can send the VK_* messages directly to your application. This includes the VK_LWIN messages from a program control.
If there is a valid VK code associated with the navigation control, this function will return that key code to your application.
This registers your application to receive messages when the user presses a navigation control.
Note The shell does not automatically launch your application if you send navigation messages directly to your application.
You can also alter the application that a program control launches by directly modifying the registry key of that program control. If you do alter the registry of a program control, you may have difficulties with the RegisterHotKey function. Because HotKeys are sent directly to the application without first passing through the shell, the shell will not notice your change. To avoid this problem, ask the user to change the associated program of the program control from the Button Properties dialog box. Optionally, you can change the registry value, and then ask the user to reboot.
When you program a navigation control, follow these guidelines:
The shell launches your application in response to a user pressing the associated program control. SHGetAppKeyAssoc returns the valid VK code of that program control.
If GetAsyncKeyState returns a VK_DOWN message, then the program control was held the entire time.
For more information about VK mapping, consult the documentation for the device driver available from the manufacturer of your target device.