How to: Handle HardwareButton Events (Devices)

Use a HardwareButton control to override the application keys on a Pocket PC.

To assign a HardwareButton component to a specific application key

  1. From the Device Components tab of the Toolbox, drag a HardwareButton component onto a Windows Form or into the Component tray in the designer.

  2. In the Component tray, right-click the HardwareButton control, and then on the shortcut menu, click Properties.

  3. Set the AssociatedControl property to the form, for example, Form1.

  4. Set the HardwareKey property to the key you want to override, for example, ApplicationKey1.

  5. Click the button, for example, Soft Key 1, on the designer's skin.

    The Code Editor opens at the Form_KeyDown event handler.

  6. Insert the following code:

    if ((int) e.KeyCode == (int) Microsoft.WindowsCE.Forms.HardwareKeys.ApplicationKey1)

    You would typically use the //TODO section to launch an application.

See Also


How to: Use the HardwareButton Component


Creating and Developing Managed Device Projects