hweyskm 0 Newbie Poster

I;m trying to make a runtime resizeable media player control, i wrote the code and it works fine in 3 dimensions but the other dimensions seem to have something wrong and i cant find it, please anyone can help? i guess the problem is in sub pbsmousemove

Public Class vid
    Private locations() As Point
    Public pb(9) As PictureBox
    Private activeControlParent As Control = Nothing
    Private horizontalMidPoint As Integer
    Private verticalMidPoint As Integer
    Private mmousedown As Boolean = False
    Public panel1 As New Panel

    Public Sub New(ByVal video As AxWMPLib.AxWindowsMediaPlayer)
        activeControlParent = panel1
        AddHandler video.MouseDownEvent, AddressOf mediaclk
        video.Dock = DockStyle.Fill
        panel1.Controls.Add(video)
    End Sub

    Private Sub pbsMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        If e.Button = Windows.Forms.MouseButtons.Left Then
            mmousedown = True
        End If
    End Sub

    Private Sub pbsMousemove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        Dim c As Control = CType(activeControlParent, Control)
        Dim g As PictureBox = sender
        If mmousedown Then
            c.SuspendLayout()
            Select Case g.Tag.ToString
                Case "0"
                    c.SetBounds(c.Left + e.X, c.Top + e.Y, c.Width - e.X, c.Height - e.Y)
                Case "1"
                    c.SetBounds(c.Left, c.Top + e.Y, c.Width, c.Height - e.Y)
                Case "2"
                    c.SetBounds(c.Left, c.Top + e.Y, c.Width - (c.Width - e.X), c.Height - e.Y)
                Case "3"
                    c.SetBounds(c.Left + e.X, c.Top, c.Width - e.X, c.Height)
                Case "4"
                    c.SetBounds(c.Left, c.Top, c.Width - (c.Width - e.X), c.Height)
                Case "5"
                    c.SetBounds(c.Left + e.X, c.Top, c.Width - e.X, c.Height - (c.Height - e.Y))
                Case "6"
                    c.SetBounds(c.Left, c.Top, c.Width, c.Height - (c.Height - e.Y))
                Case "7"
                    c.SetBounds(c.Left, c.Top, c.Width - (c.Width - e.X), c.Height - (c.Height - e.Y))
                Case "8"
                    activeControlParent.SetBounds(c.Left + e.X, c.Top + e.Y, c.Width, c.Height)
            End Select
        End If
        c.ResumeLayout()
        Form1.txt1.Text = c.Location.X.ToString
        Form1.txt2.Text = c.Location.Y.ToString
    End Sub

    Private Sub pbsMouseup(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        mmousedown = False
        For x As Integer = 0 To 8
            pb(x).Dispose()
        Next
        pbscontrols()
    End Sub
    Private Sub pbsmouseleave(ByVal sender As Object, ByVal e As System.EventArgs)
        mmousedown = False
        For x As Integer = 0 To 8
            pb(x).Dispose()
        Next
        pbscontrols()
    End Sub

    Sub pbscontrols()
        locations = New Point() _
                        {New Point(0, 0), New Point(activeControlParent.Width / 2 - 3, 0), _
                        New Point(activeControlParent.Width - 6, 0), New Point(0, activeControlParent.Height / 2 - 3), _
                        New Point(activeControlParent.Width - 6, activeControlParent.Height / 2 - 3), New Point(0, activeControlParent.Height - 6), _
                        New Point(activeControlParent.Width / 2 - 3, activeControlParent.Height - 6), New Point(activeControlParent.Width - 6, activeControlParent.Height - 6)}

        Dim sizeCursor() As Cursor = {Cursors.SizeNWSE, Cursors.SizeNS, Cursors.SizeNESW, Cursors.SizeWE, _
        Cursors.SizeWE, Cursors.SizeNESW, Cursors.SizeNS, Cursors.SizeNWSE}

        For x As Integer = 0 To 7

            pb(x) = New PictureBox
            With pb(x)
                .BackColor = Color.White
                .Size = New Size(6, 6)
                .BorderStyle = BorderStyle.FixedSingle
                .Location = locations(x)
                .Cursor = sizeCursor(x)
                .Tag = x
                activeControlParent.Controls.Add(pb(x))
                .BringToFront()
                AddHandler .MouseDown, AddressOf pbsMouseDown
                AddHandler .MouseMove, AddressOf pbsMousemove
                AddHandler .MouseUp, AddressOf pbsMouseup
                AddHandler .MouseLeave, AddressOf pbsmouseleave
            End With
        Next
        pb(8) = New PictureBox
        With pb(8)
            .BackColor = Color.White
            .Size = New Size(20, 20)
            .BorderStyle = BorderStyle.FixedSingle
            .Location = New Point(20, 0)
            .Cursor = Cursors.SizeAll
            .Tag = "8"
            activeControlParent.Controls.Add(pb(8))
            .BringToFront()
            AddHandler .MouseDown, AddressOf pbsMouseDown
            AddHandler .MouseMove, AddressOf pbsMousemove
            AddHandler .MouseUp, AddressOf pbsMouseup
            AddHandler .MouseLeave, AddressOf pbsmouseleave
        End With
        activeControlParent.Refresh()
    End Sub
    Public Sub mediaclk(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_MouseDownEvent)
        pbscontrols()
    End Sub
End Class