I've got a form that has no border
(FormBorderStyle.None), and I'd like to move it with the
mouse. My solution is below. Is there a better one?

Private Sub Form1_MouseDown(ByVal sender As Object, ByVal
e As System.Windows.Forms.MouseEventArgs) Handles
MyBase.MouseDown
MouseDownLoc.X = e.X
MouseDownLoc.Y = e.Y
End Sub

Private Sub Form1_MouseMove(ByVal sender As Object, ByVal
e As System.Windows.Forms.MouseEventArgs) Handles
MyBase.MouseMove
If e.Button = MouseButtons.Left Then
Me.Left += e.X - MouseDownLoc.X
Me.Top += e.Y - MouseDownLoc.Y
End If
End Sub

Re: Moving form with no border by Bob

Bob
Tue Nov 25 17:24:33 CST 2003

Nope, thats fine!

--
Bob Powell [MVP]
C#, System.Drawing

The November edition of Well Formed is now available.
Learn how to create Shell Extensions in managed code.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Frank McCown" <mccownf@yahoo.com> wrote in message
news:112b01c3b3aa$640a3a70$a001280a@phx.gbl...
> I've got a form that has no border
> (FormBorderStyle.None), and I'd like to move it with the
> mouse. My solution is below. Is there a better one?
>
> Private Sub Form1_MouseDown(ByVal sender As Object, ByVal
> e As System.Windows.Forms.MouseEventArgs) Handles
> MyBase.MouseDown
> MouseDownLoc.X = e.X
> MouseDownLoc.Y = e.Y
> End Sub
>
> Private Sub Form1_MouseMove(ByVal sender As Object, ByVal
> e As System.Windows.Forms.MouseEventArgs) Handles
> MyBase.MouseMove
> If e.Button = MouseButtons.Left Then
> Me.Left += e.X - MouseDownLoc.X
> Me.Top += e.Y - MouseDownLoc.Y
> End If
> End Sub



Re: Moving form with no border by hirf-spam-me-here

hirf-spam-me-here
Tue Nov 25 18:24:35 CST 2003

* "Frank McCown" <mccownf@yahoo.com> scripsit:
> I've got a form that has no border
> (FormBorderStyle.None), and I'd like to move it with the
> mouse. My solution is below. Is there a better one?
>
> Private Sub Form1_MouseDown(ByVal sender As Object, ByVal
> e As System.Windows.Forms.MouseEventArgs) Handles
> MyBase.MouseDown
> MouseDownLoc.X = e.X
> MouseDownLoc.Y = e.Y
> End Sub
>
> Private Sub Form1_MouseMove(ByVal sender As Object, ByVal
> e As System.Windows.Forms.MouseEventArgs) Handles
> MyBase.MouseMove
> If e.Button = MouseButtons.Left Then
> Me.Left += e.X - MouseDownLoc.X
> Me.Top += e.Y - MouseDownLoc.Y
> End If
> End Sub

See:

<http://www.google.de/groups?q=sendmessage+HTCAPTION+group:*dotnet*&ie=UTF-8>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>