converting bitmaps to icons at runtime

S

Scott Mead

In VB6 I was able to convert a bitmap that was in a Imagelist to an
icon via the ExtractIcon method and display the result as a form's
Icon. I need to be able to do the same in .NET. Any ideas on how
this can be done?

thanks in advance...

Scott Mead
 
K

Kevin Yu [MSFT]

Hi Scott,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to convert a bitmap image in
an ImageList to an icon at runtime. If there is any misunderstanding,
please feel free to let me know.

Based on my research, we can get the handle of a bitmap and then load the
Icon object from a handle. Here is an example:

ImageList i = new ImageList();
i.Images.Add(new System.Drawing.Bitmap(@"d:\Factory.jpg"));
System.Drawing.Icon ico =
System.Drawing.Icon.FromHandle(((Bitmap)i.Images[0]).GetHicon());
this.Icon = ico;

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
K

Kevin Yu [MSFT]

Hi Scott,

I'd like to know if this issue has been resolved yet. Is there anything
that I can help. I'm still monitoring on it. If you have any questions,
please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top