It sort of works - the thing is without clicking the picturebox or anything, the form, whenever I move the mouse, it moves any help?
Thanks

Public Class Form1

    Dim drag As Boolean
    Dim mousex As Integer
    Dim mousey As Integer

    Private Sub CloseButton1_Click(sender As Object, e As EventArgs) Handles CloseButton1.Click
        System.Environment.Exit(1)
    End Sub

    Private Sub MaximiseButton1_Click(sender As Object, e As EventArgs) Handles MaximiseButton1.Click
        If Me.WindowState = FormWindowState.Normal Then
            Me.Height = Screen.PrimaryScreen.WorkingArea.Height
            Me.Width = Screen.PrimaryScreen.WorkingArea.Width
            Me.Left = (Screen.PrimaryScreen.WorkingArea.Width - Me.Width) / 2
            Me.Top = (Screen.PrimaryScreen.WorkingArea.Height - Me.Height) / 2
        Else
            Me.WindowState = FormWindowState.Normal
        End If
    End Sub

    Private Sub MinimiseButton1_Click(sender As Object, e As EventArgs) Handles MinimiseButton1.Click
        Me.WindowState = FormWindowState.Minimized
    End Sub

    Private Sub DesireWB1_Click(sender As Object, e As EventArgs) Handles DesireWB1.Click
        Form2.Show()
    End Sub

    Private Sub PictureBox1_MouseDown() Handles PictureBox1.MouseDown
        drag = True
        mousex = Windows.Forms.Cursor.Position.X - Me.Left
        mousey = Windows.Forms.Cursor.Position.Y - Me.Top
    End Sub

    Private Sub PictureBox1_MouseMove() Handles PictureBox1.MouseMove
        Me.Top = Windows.Forms.Cursor.Position.Y - mousey
        Me.Left = Windows.Forms.Cursor.Position.X - mousex
    End Sub

    Private Sub PictureBox1_MouseUp() Handles PictureBox1.MouseUp
        drag = False
    End Sub
End Class

The MouseMove event needs to take the current state of drag into account:

Private Sub PictureBox1_MouseMove() Handles PictureBox1.MouseMove
    If drag Then
        Me.Top = Windows.Forms.Cursor.Position.Y - mousey
        Me.Left = Windows.Forms.Cursor.Position.X - mousex
    End If
End Sub

Thanks a lot :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.