it will be draggable by default if you use a formborderstyle that has a border + titlebar.
for borderless forms you can use api functions:
vb Code:
Imports System.Runtime.InteropServices Public Class Form1 Dim moveDown As Boolean = False Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown moveDown = True End Sub Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove If moveDown Then ReleaseCapture() SendMessage(Me.Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0) End If End Sub Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp moveDown = False End Sub #Region " Functions and Constants " <DllImport("user32.dll")> _ Public Shared Function ReleaseCapture() As Boolean End Function <DllImport("user32.dll")> _ Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer End Function Private Const WM_NCLBUTTONDOWN As Integer = &HA1 Private Const HTBORDER As Integer = 18 Private Const HTBOTTOM As Integer = 15 Private Const HTBOTTOMLEFT As Integer = 16 Private Const HTBOTTOMRIGHT As Integer = 17 Private Const HTCAPTION As Integer = 2 Private Const HTLEFT As Integer = 10 Private Const HTRIGHT As Integer = 11 Private Const HTTOP As Integer = 12 Private Const HTTOPLEFT As Integer = 13 Private Const HTTOPRIGHT As Integer = 14 #End Region End Class




Reply With Quote