Image change in picturebox

  • 13 years ago

     I have this issue where I have to change an image in a picturebox when a usbdevice connects..

    I have a DeviceStatusMonitor which fires when a usbdevice is connected, and calls a sub where I change an image in a picturebox...(one image for a usbconnected and the other for usb not connected).

    After insert and remove of usb key, memory is 4KB larger then before. Can someone check the code for what I am doing wrong?

    I am doing this on windows CE device (thus memory is important even 4KB :))

     Thanks Greg


    Dim diskmonitor As OpenNETCF.Net.DeviceStatusMonitor
        Public Sub StartDeviceMonitoring()
           diskmonitor = New OpenNETCF.Net.DeviceStatusMonitor(OpenNETCF.Net.DeviceStatusMonitor.FATFS_MOUNT_GUID, False)
            AddHandler diskmonitor.DeviceNotification, AddressOf diskmonitor_DeviceNotification
        End Sub

    Private Sub diskmonitor_DeviceNotification(ByVal sender As Object, ByVal e As OpenNETCF.Net.DeviceNotificationArgs)
    End Sub

    Private Delegate Sub USBConnectDelegate(ByVal usb As Boolean)
    Private USBConnectDelegate1 As New USBConnectDelegate(AddressOf USBConn)

    Public Sub USBConn(ByVal USB As Boolean)
            If PbxBackground.InvokeRequired Then
                BeginInvoke(USBConnectDelegate1, USB)
                If USB Then
                    Dim bmBack As New Bitmap(PbxBackground.Width, PbxBackground.Height)
                    Dim grBack As Graphics = Graphics.FromImage(bmBack)
                    grBack.DrawImage(PbxBackground.Image, 0, 0)
                    grBack.DrawImage(My.Resources.USB_Logo, 520, 440)
                    PbxBackground.Image = bmBack

                    PbxBackground.Image = My.Resources.Background
                End If
            End If

        End Sub


Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Anyone who considers arithmetic methods of producing random digits is, of course, in a state of sin.” - John von Neumann