简体   繁体   中英

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?

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM