Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine window snap distance

I'm working on an application that provides a snapping feature for its windows; drag one window close enough to the edge of the screen or another window, and it'll snap into place.

Windows 7 offers a built-in snap feature, and for consistency's sake I would like to get the "how close does this window need to be to be snapped" metric from the OS when possible. GetSystemMetrics doesn't seem to have anything particularly useful, however, and the DWM docs are similarly unhelpful.

Is there any way I can programatically get this metric?

like image 837
cf stands with Monica Avatar asked Mar 27 '26 00:03

cf stands with Monica


1 Answers

Actually there is no such metric because the "snap distance" you are looking for is actually always 0.

When you drag a toplevel window on Windows 7 (and possibily Windows 8, not sure about that), it actually snaps as soon as the mouse pointer hits the edge of the screen.

The "snap system" you want, snaps the dragged window in place as soon as one of it's edges comes closer than x to the edge of another window or to the edge of the screen, where x is the distance you are looking for (typically 10 pixels or so).

like image 96
Jabberwocky Avatar answered Mar 29 '26 14:03

Jabberwocky