Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
4/14/2010

Most devices for Windows Mobile Professional and Windows Mobile Classic include several program keys. These are typically small keys above or below the screen. By default, these are associated with applications such as Calendar or Contacts, but the user can change these associations by using the Buttons utility in Settings. You could programmatically change these associations permanently, but this is not recommended because it could unnecessarily limit the user's options. However, you might want to want to enhance or extend the behavior of a program key in relation to its associated application.

One example of a useful way to respond to these keys from within an application is the Calendar application that is included on Windows Mobile Professional and Windows Mobile Classic. The user can switch between the Calendar views by using the menu bar icons across the bottom of the screen. However, when Calendar is associated with a program key, pressing that key when Calendar is displayed can also cycle through the views. This is a very handy feature for one-handed navigation that you might want to consider for your applications.

You can also use the press-and-hold feature of a program control to create a new document. This process is similar to clicking Newon the Filemenu on a desktop computer. For detailed instructions, see How to Program a Press-and-Hold Feature.

Other potential uses for the program keys include the following:

To manage the program-key associated behavior of your application, the application should call SHGetAppKeyAssocat startup to determine whether it has an associated program key. If there is an association, the application uses the Windows Embedded CE RegisterHotKeykeyboard function to receive WM_HOTKEYmessages, rather than letting the shell handle the key. See How to Modify Program Key Behaviorfor a detailed example.

If the application receives a WM_HOTKEYmessage while it is active (the application currently on top of the z–order and in use), the application can take some action, such as switching view. If the application is not on the screen when it receives the WM_HOTKEYmessage, it should instead start itself and come to the front where the user can see it.

If your application cannot register its keyboard shortcut, it is probably because another application has registered it first. The alternatives are to proceed without the keyboard shortcut, find the other application that has registered the keyboard shortcut and send it a WM_CLOSEmessage (not recommended), or alert the user that the key cannot be registered. The recommended choice is to ignore the problem and proceed without the keyboard shortcut.

See Also