[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.drawing

how to set an application icon?

Assaf Wodeslavksy

10/17/2004 12:32:00 PM

hi all

i drew an icon.
i want to set my form to use it as the icon.
but when i set the form's icon property to
the new icon file,
it displays an icon unlike the one i drew.
what am i doing wrong?

how can i set my app icon?


assaf



2 Answers

Morten Wennevik [C# MVP]

10/18/2004 6:03:00 AM

0

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]

Assaf Wodeslavksy

10/18/2004 1:18:00 PM

0

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]