Assaf Wodeslavksy
10/18/2004 1:18:00 PM
hi morten
the problem is:
when i set the Icon property in my form,
the form does not display the icon to the file i set it to.
rather, the form displays the original icon in the raw file
(the image of the page with the small fold in the upper right corner).
in any case,
for now,
i gave up on the dot net studio's ability
to set the Icon property for a form.
therefore,
i added code to load the file:
//ctor
FormMainClient()
{
this.Icon = FormMainClient.LoadIcon(sIcon);
}
private static Icon LoadIcon(string sIcon)
{
Assembly a = Assembly.LoadFile(Application.ExecutablePath);
string [] names = a.GetManifestResourceNames();
Stream s = a.GetManifestResourceStream(sIcon);
Image image = Image.FromStream(s);
Bitmap b = (Bitmap)image;
IntPtr ip = b.GetHicon();
Icon icon = Icon.FromHandle(ip);
return icon;
}
this code works nice.
however, it also has a problem with it.
when i change the image in the visual studio designer,
it has no effect on my application icon at runtime.
the app seems to remeber the original image.
assaf
"Morten Wennevik" <MortenWennevik@hotmail.com> wrote in message
news:opsf1xq3rsklbvpo@pbn_computer...
> Hi assaf,
>
> Do you mean the Icon you see for your file in Explorer?
> You need to set that icon in your project properties, or use /win32icon
> when compiling.
> If you mean a the Icon you see on the Taskbar etc. Changing that Icon
> requires you to reattach the icon to your program or changes won't be
seen.
>
> --
> Happy Coding!
> Morten Wennevik [C# MVP]