Disclaimer: I am a hack of a programmer, doesn't really understand all that the code is doing, just trying to finish a little homemade project.
Everything runs fine until you get to that line


Everything runs fine, it doesn't show any controls in the tab window when I have the code following from DrawBox running there. I can kind of understand why, because it's probably trying to draw when that box is on another tab and not at those X&Y Cords. There must be a smarter way to do this... I can upload the project or all of the code, if that's easier.

Code:
    Dim Touchless1 As New TouchlessLib.TouchlessMgr


    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        StartCapture()
    End Sub

    Public Sub StartCapture()
        If Touchless1.Cameras.Count = 0 Then MessageBox.Show("This application needs a webcam") : Return
        Touchless1.CurrentCamera = Touchless1.Cameras.First
        AddHandler Touchless1.CurrentCamera.OnImageCaptured, AddressOf CaptureInvoke
    End Sub

    Private Sub CaptureInvoke()
        picCapture.Image = Touchless1.CurrentCamera.GetCurrentImage()
        'DrawBox()
    End Sub

    Private Sub DrawBox()

        Try   'This is the Crop and Draw Box on changing picturebox
            cropX = Convert.ToInt32(lblX.Text)
            cropY = Convert.ToInt32(lblY.Text)
            cropWidth = Convert.ToInt32(lblWidth.Text)
            cropHeight = Convert.ToInt32(lblHeight.Text)

            Dim g As Graphics = picCapture.CreateGraphics

            cropPen = New Pen(cropPenColor, cropPenSize)
            cropPen.DashStyle = cropDashStyle

            g.DrawRectangle(cropPen, cropX, cropY, cropWidth, cropHeight)

        Catch exc As Exception
            MessageBox.Show(exc.Message, " Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try

    End Sub
Maybe I could throw some If picCapture.Focused = True then ...or something??? (I tried that and got: Cross-thread operation not valid: Control 'picCapture' accessed from a thread other than the thread it was created on.) I get that error a lot, what am I doing wrong? I was trying to get better code to crop a picturebox anyhow: http://www.vbforums.com/showthread.php?p=3905804