Hi. I've got an app that uses a Systray icon.
I have the icon doing an 'animation' every five seconds to indicate program is still running.
Icons are stored in a Forms.Imagelist collection (imglSystrayIcons).
I have a form timer to swap out the icons:
The code works well for about the first hour.
Then the debugger stops on the highlighted line with the message "Generic Error Occurred in GDI+" .
Is this not a good technique to do this?
I have the icon doing an 'animation' every five seconds to indicate program is still running.
Icons are stored in a Forms.Imagelist collection (imglSystrayIcons).
I have a form timer to swap out the icons:
Code:
Private Sub tmrSystrayIcon_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
'as long as program is enabled
If Me.chkSchedulerEnabled.Checked = True Then
If Now.Second Mod 5 = 0 Then
'show washed-out icon
[COLOR=black yellow]Me.SystrayIcon.Icon = ImageToIcon(Me.imglSystrayIcons.Images(2))[/color]
Else
'show solid icon
Me.SystrayIcon.Icon = ImageToIcon(Me.imglSystrayIcons.Images(1))
End If
End If
End Sub
Private Function ImageToIcon(ByVal image As System.Drawing.Image) As System.Drawing.Icon
Try
Return System.Drawing.Icon.FromHandle(New Bitmap(image).GetHicon)
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Function
The code works well for about the first hour.
Then the debugger stops on the highlighted line with the message "Generic Error Occurred in GDI+" .
Is this not a good technique to do this?