GetHicon - A general error occurred in GDI+

Orumcek
08-02-2006, 09: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.
Regards.

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
Else
ico = 0
End If

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

Iceplug
08-06-2006, 06: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())
etc.

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) :-\

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

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

Regards.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum