title: Move form when panel is clicked and dragged
body: <p>I'm trying to make my form move (like you move windows on other applications) when I click and hold my panel element (which serves as top of the window cause I used custom made GUI).</p>
  
  <p>Anyways, I managed to make it move but the problem is, the form moves to my current cursor position when I click on it instead of moving like a regular window (cause it reads the cursor's position and sets the form's location to that position, thus moving it unnecessary).</p>
  
  <p>This is my code, what can I do to get it to work properly?</p>
  
  <pre><code>Dim Moving As Boolean = False
  
  
   Private Sub Panel1_MouseDown(sender As Object, e As MouseEventArgs) Handles Panel1.MouseDown
      Moving = True
      MouseMoveTimer.Start()
  End Sub
  
  Private Sub Panel1_MouseUp(sender As Object, e As MouseEventArgs) Handles Panel1.MouseUp
      Moving = False
      MouseMoveTimer.Stop()
  End Sub
  
  Private Sub MouseMoveTimer_Tick(sender As Object, e As EventArgs) Handles MouseMoveTimer.Tick
      Me.Location = Cursor.Position
  End Sub
  </code></pre>
  
  <p>New code</p>
  
  <pre><code>Dim diff As Point = Cursor.Position - curpoint
          Me.Location -= diff
          curpoint = Cursor.Position
  </code></pre>