How to: Process Mouse Events (Devices)

Besides using skins to provide a visual replica of a real device, you can also use them to process mouse events, which makes the emulation of real devices even more realistic.

By assigning a unique color (mappingColor) to each button area in the Skin Definition File, you can specify what occurs when you hover, click, or press and hold the pointer over any button on the skin. You may not be able to see the color in the user interface. It serves only to provide a unique indicator for event handling in the Device Emulator and Visual Studio designers.

For example, if you use your graphic tool to view the file PocketPC_2003_Mask.png, installed by default at drive:\Program Files\Microsoft Visual Studio 9.0\SmartDevices\Skins\PocketPC_2003\PocketPC_2003\1033, you see that each button appears with a distinct color.

Note

Windows Mobile 5 and 6 SDKs are installed outside the Visual Studio folder, for example, Program Files\Windows Mobile 5.0 SDK R2 and Program Files\Windows Mobile 6 SDK.

To process an onClick event

  1. In a button tag in the Skin Definition File, assign a color value to mappingColor.

    The following example is from the Pocket PC 2003 Skin Definition File:

    <button
        toolTip="Soft Key 1"
        onClick="DOWN:0x5b 0x70 UP:0x5b"
        mappingColor="0xF26C4F"
    />
    
  2. Assign keystrokes to the onClick event.

    For more information, see the following steps to associate a button with a keystroke.

    If you click the button that has the color 0xF26C4F, the onClick event specified in this button section will be handled. The keystrokes specified in the Skin Definition File are passed to the engine.

To process an onPressAndHold event

  1. In a button tag in the Skin Definition File, assign a color value to mappingColor.

    The following example is from the Pocket PC 2003 Skin Definition File:

    <button
        toolTip="Power"
        onPressAndHold="0x75"
        mappingColor="0xED145B"
    />
    
  2. Assign a keystroke to the onPressAndHold event.

    For more information, see the following steps to associate a button with a keystroke.

    If you click any button that has the color 0xED145B, the onPressAndHold event specified in this button section is handled.

To associate a button with a keystroke

  • Use either the keyboard scan code, as in the previous examples or a set of predefined constants, such as Key_Down.

    For more information, see Emulator Skin XML Schema in the MSDN Library.

See Also

Other Resources

Customizing Skins (Devices)