By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,237 Members | 1,842 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,237 IT Pros & Developers. It's quick & easy.

Use icons in shell32.dll for buttons on form?

P: n/a

Any tips on using the icons in shell32.dll as the image on a button in a
form?

Thanks.
Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Try this

[DllImport("Shell32.dll")]
public extern static int ExtractIconEx( string libName, int iconIndex,
IntPtr[] largeIcon, IntPtr[] smallIcon, int nIcons );

int numIcons = 10;//if you want 10 icons for example

IntPtr[] largeIcon = new IntPtr[numIcons ];
IntPtr[] smallIcon = new IntPtr[numIcons ];

usage -

ExtractIconEx( "shell32.dll", 0, largeIcon, smallIcon, numIcons );

//retrieve icon from array
Icon largeIico = Icon.FromHandle( largeIcon[0]);
Icon smallIco = Icon.FromHandle( smallIcon[0]);

The first parameter of ExtractIconEx can be use to get icons for exe or dll.

--
Shak
(Houston)


"emde" <em**@na.com> wrote in message
news:#V**************@TK2MSFTNGP10.phx.gbl...

Any tips on using the icons in shell32.dll as the image on a button in a
form?

Thanks.

Nov 16 '05 #2

P: n/a

Cool this seems to work fairly well. For a standard button I used:

chooseFileButton.Image = iconToUse.ToBitmap();

This works, but the image on the button looks like it needs some type of
alpha channel (black?) to have the correct transparency.

Any ideas on this?

Thanks again.
Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.