DragDetect function (Windows)

Switch View :
ScriptFree
DragDetect function

Applies to: desktop apps only

Captures the mouse and tracks its movement until the user releases the left button, presses the ESC key, or moves the mouse outside the drag rectangle around the specified point. The width and height of the drag rectangle are specified by the SM_CXDRAG and SM_CYDRAG values returned by the GetSystemMetrics function.

Syntax

BOOL WINAPI DragDetect(
  __in  HWND hwnd,
  __in  POINT pt
);

Parameters

hwnd [in]

Type: HWND

A handle to the window receiving mouse input.

pt [in]

Type: POINT

Initial position of the mouse, in screen coordinates. The function determines the coordinates of the drag rectangle by using this point.

Return value

Type: BOOL

If the user moved the mouse outside of the drag rectangle while holding down the left button, the return value is nonzero.

If the user did not move the mouse outside of the drag rectangle while holding down the left button, the return value is zero.

Remarks

The system metrics for the drag rectangle are configurable, allowing for larger or smaller drag rectangles.

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

See also

Conceptual
Mouse Input
Reference
GetSystemMetrics
POINT

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Community Content

stickboy
DragDetect also seems to return TRUE if clicking and holding
DragDetect also seems to return TRUE if clicking on the window and holding the mouse button down for some amount of time. (My colleague suspects that it's tied to the double-click time.)