ImageList Image to Icon

Nazgulled

Centurion
Joined
Jun 1, 2004
Messages
119
Hi,
I've been searching a lot for this and I found a solution but not exactly working as I expected.
I have an ImageList with a list of images in PNG format and I want to add one of those images to the icon propertie in a status bar for instance.

The image on ImageList is System.Drawing.Bitmap and the icon on the statusbar is System.Drawing.Icon, that means I can't do this:
Code:
Me.StatusBar1.Icon = Me.ImageList1.Images(0)

so, after my search I found this, wich works:
Code:
Dim icoStatus As Icon
icoStatus = Icon.FromHandle(DirectCast(Me.ImageList1.Images(0), Bitmap).GetHicon)
            Me.StatusBar1.Panels(0).Icon = icoStatus

However, the problem is right here, the transparency of the iamge is not there and so the images looks weird, but it works; but I want it to work with transparency. By the way, I tested with PNG and ICO files, but the results were the same.

If I load the image directly from my hard drive to the icon property, it works fine, the transparency is there.
So, what can I do to ahve the trasnparency stay there using and ImageList? I want this because the status bar will have a different image depeding on some factors.

Any help?
 
Maybe I expressed myself wrong... The graphics are alpha-blended, not transparent.
And like I said, it works if I load them directly but it doesn't work if I add them to an Imagelist and then convert them using the code above. I suppose that if it worksadding them directly there must be a way to it coding it.
 
What I meant by directly was in the panel properties, you just load the icon, all alpha-blended colors with still be there.

But I fixed the problem with a workaround. I used the sandbar control on my app, so I loaded the icons I wanted to some menu options and made the parent menu invisible and I just associate the menu icons to the status bar icon whenever I need it.
 
Back
Top