Get a form's small icon

O

\(O\)enone

I wish to be able to copy a form's icon into a picturebox, in a similar way
to how the Windows Taskbar copies each form's icon into each of its task
panels.

I can easily read out the icon of each form by querying the .Icon property.
However, when I use the Graphics.DrawIcon method to draw this into my
picturebox, it is clearly the "large" version of the icon that is being
drawn. When I draw it with a size of 16x16 pixels, the icon is visibly
distorted compared to the original displayed in the window itself; when I
draw at 32x32 the image is fine and undistorted, but twice the size that I
want it to be.

If there a way for me to extract the small icon for each form so that I can
draw it without it distorting?

Thanks in advance,
 
G

G Himangi

You can try using the overlaoded constructor :
Icon Constructor (Icon, Size) : Initializes a new instance of the Icon class
and attempts to find a version of the icon that matches the requested size.
---------
- G Himangi, Sky Software http://www.ssware.com
Shell MegaPack : GUI Controls For Drop-In Windows Explorer like Shell
Browsing Functionality For Your App (.Net & ActiveX Editions).
EZNamespaceExtensions.Net : Develop namespace extensions rapidly in .Net
EZShellExtensions.Net : Develop all shell extensions,explorer bars and BHOs
rapidly in .Net
---------
 
O

\(O\)enone

G said:
You can try using the overlaoded constructor :
Icon Constructor (Icon, Size) : Initializes a new instance of the
Icon class and attempts to find a version of the icon that matches
the requested size.

That works perfectly -- many thanks!
 

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