Is the form you want to snap to a real Form that is owned by your application, or is it just a window In the first case, you might be able to avoid api calls. If you just mean snapping to any window, then you'll have to enumerate the windows.
I actually did something like this quite a while ago in VB6 using subclassing, which in C# would be equivalent to overriding the WndProc method in the Form and intercepting the WM_MOVE message, probably.
Another issue is if you want your snapped form to move when you move the other form. This would be very difficult if you do not own the other form, and cannot modify its code.
How to Make Form "Snap" to the Screen Edge of Another Form?
Hugo Soares
Use this code to snap a form to the upper left corner of the main form:
Form
f1 = new Form();f1.StartPosition =
FormStartPosition.Manual;f1.Location =
new Point(this.Location.X, this.Location.Y);f1.Show(
);Stephie
How about just snapping it to the bottom of another window
Thanks.
WolfgangEngel
I actually did something like this quite a while ago in VB6 using subclassing, which in C# would be equivalent to overriding the WndProc method in the Form and intercepting the WM_MOVE message, probably.
Another issue is if you want your snapped form to move when you move the other form. This would be very difficult if you do not own the other form, and cannot modify its code.
Bunk
Thanks.
airwalker2000
Yes. I do own all the the forms.
It will not snap to other application that is running in Windows.
I have main form and let say a child form. The child form will 'snap' to the main form when it is near to any of the borders of the main form.
I would like to avoid using Windows API e.g. WndProc commands.
Can it do it purely on C#
Thanks!
yog_23
But how to make it dock to any side of the form