GetHicon - A general error occurred in GDI+

08-02-2006, 08:41 AM
Hi All,

I have 4 icon on my project and i change icon every 150 milisecond and create animation. I want icons embeded. There fore i use image list and store they.

So, after a short while i get "A general error occurred in GDI+". I think, handle needs to be released to free memory. But how can i do ?

Thank you.

My Animation Sub:

Private Sub animTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles animTimer.Tick
If ico < 3 Then
ico = ico + 1
ico = 0
End If

'Change Icon
NotifyIcon1.Icon = System.Drawing.Icon.FromHandle(CType(imgList.Images.Item(ico), System.Drawing.Bitmap).GetHicon())
End Sub

08-06-2006, 05:42 AM
Why not just make an array containing the four icons?

Load them all there into the array:
Icons(0) = System.Drawing.Icon.FromHandle(CType(imgList.Images.Item(ico), System.Drawing.Bitmap).GetHicon())

and then do
NotifyIcon1.Icon = Icons(ico)

Though, I don't know how effective it will be by changing a notifyicon every 150 ms. I don't think my systray updates that frequently... (maybe it does) :-\

08-07-2006, 08:55 AM
Hi Iceplug,

Your idea very simple, but very useful for me. Thank you very much. Simple is fine :)


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum