tags:

views:

95

answers:

2

I have a borderless window (BorderStyle = None) where I would like to allow the user to click on the background (anywhere but one of the child controls) and move it around.

How would I go about doing that?

Thank you,

+2  A: 

Try this.

http://www.codeproject.com/KB/cs/csharpmovewindow.aspx

GONeale
A: 

You just need to override OnMouseDown/OnMouseMove/OnMouseUp. These three methods provide the mouse events to move your form.

When the mouse is pressed, just track the mouse location. On move events, move the form with the mouse, and when the mouse is released, stop "moving".

Reed Copsey
The SendMessage/ReleaseCapture way is much better since it lets the Window Manager handle the form movement.
Joey
It's nice, if you're willing to PInvoke. There are times when platform invoke is not desired, though, in which case this works as well.
Reed Copsey