Windows Develop Bookmark and Share   
 index > Windows Forms General > How do I convert a .gif image into Icon?
 

How do I convert a .gif image into Icon?

Hi,

I have several gif images as embedded resources in my C# project.
I am able to load them and display them on a buttons, pictureboxs etc.
But I want to load the same gif image and set it as the Icon for my form.

How do I convert my embedded .gif resource into Icon programatically
(without embedding another .ico file for each .gif image)?

thanks,
- Reddy
MigrationUser 1  Wednesday, April 16, 2003 3:36 AM
I got it to work. 

-------------------------------------------------------------------------------
Image img =  Image.FromStream(
typeof(Form1).Module.Assembly.GetManifestResourceStream(
"IconTest.myimage.gif"));

Bitmap bm = new Bitmap(img);
IntPtr iptr = bm.GetHicon();

Icon icon = Icon.FromHandle(iptr);
this.Icon = icon;
bm.Dispose();
img.Dispose();
-------------------------------------------------------------------------------

Thought I would share this with you...

- Reddy
MigrationUser 1  Tuesday, May 06, 2003 12:23 AM
Thanks for that - just what the mgr ordered...  ;) 
MigrationUser 1  Tuesday, August 05, 2003 6:22 PM

You can use google to search for other answers

Custom Search

More Threads

• WinForms MenuStrip Bug
• Iterating an enumeration with a timer control
• ComboBox.FindString bug?
• unload me
• Create a frame enviroment in C# using Visual Studio
• Displaying images on a form using code
• Num Lock
• how to create a user defined Events work for the following topic
• Loading files into forms
• Personalization and windows forms? Is it possible?