Stylus

In many Microsoft® Windows® CE .NET–based applications, the user interacts with an application by using a stylus and a touch screen. The stylus and the touch screen provide a direct and intuitive alternative to a mouse.

The stylus generates an input event when the user touches the screen with a stylus or moves the stylus when the tip is touching the screen. To an application, stylus input is a subset of mouse input. When the user presses and releases the stylus on the screen, the application processes these events as a click of the left mouse button. When the user moves the stylus across the screen, the application processes this action as a movement of a mouse.

Input events generated by the action of the stylus in a window are posted to the message queue of the thread that created the window. A window receives a stylus message when a stylus event occurs within the window client area. When the user presses the stylus to the screen, the window receives a WM_LBUTTONDOWN message. When the stylus is lifted from the screen, the window receives a WM_LBUTTONUP message. Occasionally, a window receives a WM_LBUTTONDBLCLK message instead of a WM_LBUTTONDOWN message. Substitution of a WM_LBUTTONDBLCLK message for a WM_LBUTTONDOWN message occurs under the following conditions:

  • The window class was registered by using the CS_DBLCLKS class style.
  • The stylus touches the screen within a certain distance of the last stylus location.
  • The stylus touches the screen within a certain time limit after the stylus last touched the screen.

If the user moves the stylus while pressing it to the screen, Windows CE generates a WM_MOUSEMOVE message.

The following table shows the messages related to stylus input that Windows CE supports.

Message Description
WM_LBUTTONDBLCLK The user double-tapped the screen.
WM_LBUTTONDOWN The user pressed the screen.
WM_LBUTTONUP The user released the stylus from the screen.
WM_MOUSEMOVE The user moved the stylus while the tip was pressed to the screen.

The lParam parameter of a stylus message indicates the position of the stylus tip. The low-order word is the x-coordinate and the high-order word is the y-coordinate. The coordinates are specified in the client coordinates. In the client-coordinate system, all points are specified in relation to the upper-left corner of the client area.

The wParam parameter contains flags that indicate the status of the CTRL and SHIFT keys at the time of the stylus event. Check for these flags when the way you process a stylus event depends on the state of the CTRL or SHIFT key.

The following table shows the flags that you can set in the wParam parameter.

Value Description
MK_CONTROL The CTRL key is down.
MK_LBUTTON The stylus is touching the screen.
MK_SHIFT The SHIFT key is down.

 Last updated on Wednesday, April 14, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.