Dragging a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I have a form with borderstyle set to None, so i don't have a title bar
I would like to drag my form by dragging a label on the form, instead of the title bar
can anyone give me a hint

than
 
Hi Tom,

my suggestion would be fix the labelsize and position and use drag event
from the label to move the form equally x,y -coords

I'm thinking like. When user click and drag the label, loop and restore the
label position but move the form.

/anders
 
'to move the form
Private Sub frmMain_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
mouse_offset = New Point(-e.X, -e.Y)
End Sub

Private Sub frmMain_MouseMove(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
If e.Button = MouseButtons.Left Then
Dim mousePos As Point = sender.findform().MousePosition
mousePos.Offset(mouse_offset.X, mouse_offset.Y)
sender.findform().Location = mousePos
End If

End Sub
 
Back
Top