Touch Drag and Drop in Windows Mobile 6.5
Windows Mobile 6.5 modernized the legacy Windows CE user interface by introducing touch-friendly features, kinetic scrolling, and improved gesture handling to an operating system historically built for stylus input. This article examines how Windows Mobile 6.5 handled touch drag-and-drop operations natively and programmatically, detailing the underlying Win32 mouse emulation, the dedicated Gesture API, and the developer techniques required to implement smooth direct-manipulation mechanics within mobile applications.
Win32 Pointer Emulation
At its core, Windows Mobile 6.5 inherited the Windows CE 5.2 kernel and its legacy messaging system. By default, touch interactions were translated into standard desktop-like mouse messages:
WM_LBUTTONDOWN: Fired when a finger or stylus made contact with the screen.WM_MOUSEMOVE: Continuously fired as the touch point traveled across the digitizer.WM_LBUTTONUP: Fired upon lifting the contact point from the display.
Applications implemented traditional drag-and-drop using these
messages. A drag sequence was typically triggered when a
WM_MOUSEMOVE exceeded a specific pixel threshold (often
defined by GetSystemMetrics using SM_CXDRAG
and SM_CYDRAG) after a downward tap. Once that movement
threshold was crossed, developers would capture the pointer using
SetCapture() to ensure all subsequent drag movements were
routed to the active control until ReleaseCapture() was
called on release.
The Windows Mobile 6.5 Gesture API
To address the limitations of treating fingers like single-pixel
mouse clicks, Windows Mobile 6.5 introduced native touch gesture support
via the WM_GESTURE message. This allowed the operating
system to differentiate between deliberate drag operations, scrolls, and
casual taps.
When a user placed a finger on the screen and moved it, the system
generated a WM_GESTURE message with an associated
GESTUREINFO structure containing coordinates and the
gesture ID:
GID_PAN: Handled continuous drag operations, tracking the initial coordinate, the delta movement, and velocity.GID_HOLD: Detected a sustained touch without significant movement, commonly used to select or "pick up" an item before dragging it.GID_BEGINandGID_END: Signaled the start and completion of a multi-part gesture sequence.
Developers registered interest in gestures using the
SetGestureConfig API. If an application wanted custom
drag-and-drop handling for a control, it could selectively enable
GID_PAN and GID_HOLD while disabling native
flick or physics scrolling behaviors that might otherwise interfere with
manual item placement.
Distinguishing Drag-and-Drop from Scrolling
Because finger dragging was also the primary method for kinetic scrolling in Windows Mobile 6.5, avoiding conflicts between panning a view and dragging an individual item was a core design challenge. Developers handled this in two ways:
- Tap-and-Hold Initiation: Applications used the
SHRecognizeGestureAPI or intercepted theGID_HOLDgesture. A visual cue—such as an animated circle of dots or an item elevation effect—indicated that an item was detached from the list, locking scrolling and converting subsequent movement strictly into item repositioning. - Dedicated Drag Handles: For controls like reorderable lists, developers restricted drag activation to a specific visual touch target (such as an icon on the edge of a row). Movement on the handle initiated dragging, while movement across the rest of the element triggered standard kinetic list scrolling.
Implementation in Managed Code (.NET Compact Framework)
For enterprise and third-party software written in C# or VB.NET using
the .NET Compact Framework 3.5, native WM_GESTURE messages
were not automatically mapped to managed drag events.
Managed developers implemented drag-and-drop by overriding the
OnMouseDown, OnMouseMove, and
OnMouseUp control methods, or by subclassing controls with
custom message windows (MessageWindow) to intercept
WM_GESTURE and Win32 capture APIs via Platform Invoke
(P/Invoke). This enabled managed interfaces to provide touch reordering,
slider control, and file placement with minimal performance overhead on
resource-constrained devices.