What happens if I drag the mouse by exactly the amount specified by SM_CXDRAG?

Raymond Chen

The drag sensitivity is specified by the system metrics SM_CXDRAG and SM_CYDRAG. What happens if I drag the mouse by exactly the amount specified by these two parameters?

Nothing.

These parameters control the drag insensitivity of the mouse. If your mouse motion is less than or equal to this amount, then nothing happens. This is spelled out in the documentation for GetSystemMetrics:

The number of pixels on either side of a mouse-down point that the mouse pointer can move before a drag operation begins.

It’s how far the mouse can move before the system detects a drag. In code, the algorithm is as follows:

BOOL ShouldStartDragging(POINT ptStart, POINT ptCur)
{
    RECT rc = { ptStart.x, ptStart.y, ptStart.x, ptStart.y };
    InflateRect(&rc, GetSystemMetrics(SM_CXDRAG),
                         GetSystemMetrics(SM_CYDRAG));
    return !PtInRect(&rc, ptCur);
}

Some people appear to have read a bit too much into the fluffy description of this setting. I wrote the text to be vague so I wouldn’t have to go into annoyingly precise details. It specifies how far the mouse must move, but I didn’t say exactly how. Otherwise, the text (which is pretty full already) would have had to say something unwieldy like “Drag sensitivity specifies the distance (in pixels) beyond which the mouse must move with the button held down…” I did say that “the icon will begin dragging when you have moved the mouse the necessary distance.” This was my way of saying, “The test icon shows you what happens. Just fiddle with the setting until the test icon behaves the way you like.”

In retrospect, I could’ve simply changed the word must to can.

0 comments

Discussion is closed.

Feedback usabilla icon