0

I am trying to refresh PictureBox ImageLocation. Right now this works, but I would like images that are in "landscape" mode to show up landscape in my form. I can make that possible by using image.RotateFlip() and using a load beforehand.

But when I try to refresh the picture (using a timer control and another function to grab the screenshot using adb), it doesn't like to refresh. Using breakpoints shows that it continues to refresh. even when I add other items such as refresh, update, image = nothing.. it still does not refresh or clear the image.

Is Timer or Load the culprit?

Delegate Sub SetPicCallback([text] As String, ByVal [X] As Integer, ByVal [Y] As Integer, [label] As PictureBox)
Public Sub SetPic(ByVal [text] As String, ByVal [X] As Integer, ByVal [Y] As Integer, ByVal [label] As PictureBox)

    ' InvokeRequired required compares the thread ID of the 
    ' calling thread to the thread ID of the creating thread. 
    ' If these threads are different, it returns true. 
    If [label] IsNot Nothing Then
        For Each ctrl As PictureBox In myPics
            If ctrl.Name = [label].Name Then
                If ctrl.InvokeRequired Then
                    Dim d As New SetPicCallback(AddressOf SetPic)
                    Me.Invoke(d, New Object() {[text], [X], [Y], [label]})
                Else
                    With ctrl

                        .Width = [X] / 4
                        .Height = [Y] / 4
                        .Image = Nothing
                        .ImageLocation = [text]
                        '.Load([text])
                        'If [X] > [Y] Then
                        '    .Image.RotateFlip(RotateFlipType.Rotate270FlipNone)
                        'End If
                    End With
                End If
            End If
        Next
    End If
End Sub
Solarplex
  • 107
  • 2
  • 9
  • 1
    This is a traditional VB.NET bug, you are updating the wrong `Me`. Some background in [this post](http://stackoverflow.com/a/4699360/17034). – Hans Passant Jul 08 '15 at 08:54
  • http://pastebin.com/VcZUTE03 I converted the c# things that were in that post. Still nothing. Are you talking about the Me.Invoke? Because when I try to refresh the picturebox, it doesn't even activate the invoke - it just looks through ImageLocation again but never updates the actual image. Does loading the image cause me to not be able to create a new image in its place? Because when I click get screen again, the image does not change. I'm going to check that right now. – Solarplex Jul 08 '15 at 23:53

0 Answers0