Form Icon

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form , I want to change form icon relate to some states,
I all image list witch include some icons.
How can I convert image to Icon or how to change the form icon ....in run time
 
Here is some code to convert image to icons:
FileStream fs = new FileStream(@"C:\image.bmp",System.IO.FileMode.Open);
Image img = Image.FromStream(fs);
FileStream mStr = new
FileStream(@"C:\testsmall.jpg",System.IO.FileMode.Create );
Image imgThumb= img.GetThumbnailImage(100,100,null,new IntPtr());

imgThumb.Save(mStr,System.Drawing.Imaging.ImageFormat.Jpeg);
mStr.Close();
fs.Close();

You can modify it.
To change icon of form just use YouForm.Icon = youicon; in runtime

Hope that helps
--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "


I have a form , I want to change form icon relate to some states,
I all image list witch include some icons.
How can I convert image to Icon or how to change the form icon ....in run
time
 
Hi Tamir,

I tried your code, but i found that there is no ICON encoder
(bmp & Jpeg doesn't seem to work).
Could you give us any working example?

Cheers!

Marcin
 
this.Icon = Icon.FromHandle(new Bitmap(imageList1.Images[0]).GetHicon());

This works ;)
 
Hi Tamir,
this.Icon = Icon.FromHandle(new Bitmap(imageList1.Images[0]).GetHicon());

Thank You!

I tried to do the same, but in much (much...) more complicated way.
:)

Regards

Marcin
 
Back
Top