Question Detecting nearby program and snapping your application to it

tim8w

Well-known member
Joined
Sep 8, 2020
Messages
133
Programming Experience
10+
Is there a way as I'm dragging my WinForms program around the desktop, to detect another program within a certain amount of pixels and snap to it?
 
Last edited:
Yes. You'll need to enumerate all the top level windows, get their window rectangle bounds, and compare your current forms window rectangle bounds with those that you find. I don't know what is currently available in the API unification project that Microsoft is working on and if that enumeration and window rectangle query is already available in it. If it is not yet there, you can always fall back on P/Invoke calls.
 
Back
Top Bottom