Loading Icon Resource from Win32 DLL

T

Tyler

Is there a nice way in the .NET framework to load an icon resource that is
embedded within a Win32 DLL? I noticed that the SystemIcons class comes
close (it is probably invoking the same Win32 call I need to invoke), but
doesn't allow me to specify an icon name.

I have also looked at the Icon class, but it doesn't seem to have anything
to do what I want either. I would like to avoid having to use interop to
get the HICON and the create an Icon class.

Thanks, Tyler
 
H

Herfried K. Wagner [MVP]

Tyler said:
Is there a nice way in the .NET framework to load an
icon resource that is embedded within a Win32 DLL? I
noticed that the SystemIcons class comes close (it is
probably invoking the same Win32 call I need to invoke), but
doesn't allow me to specify an icon name.

There is nothing in the framework, but you will find a nice sample there:

<http://vbaccelerator.com/article.asp?id=4567>
 
M

Mattias Sjögren

Tyler,
Is there a nice way in the .NET framework to load an icon resource that is
embedded within a Win32 DLL?

Not really, I think you have to call the ExtractIconEx Win32 API.



Mattias
 
T

Tyler

Do you know whether ownership of the HICON is taken over by the Bitmap class
when I do a Bitmap.FromHIcon or must I call DestroyIcon after creating a
bitmap from the Icon? Is there anyway to tell that from the .NET
documentation?

Thanks again for your assistance, Tyler
 
Y

Ying-Shen Yu[MSFT]

HiTtyler,
Thanks for using MSDN Newsgroup!
Bitmap class just uses the Icon handle, it will not take the ownership
of that handle, so you need
destroy it by yourself.
If you have any further questions on this issue, pleaset le me know.
Thanks!


Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!

--------------------
| From: "Tyler" <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| References: <[email protected]>
<[email protected]>
| Subject: Re: Loading Icon Resource from Win32 DLL
| Lines: 28
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <[email protected]>
| Date: Tue, 30 Sep 2003 03:13:35 GMT
| NNTP-Posting-Host: 24.192.11.167
| X-Complaints-To: (e-mail address removed)
| X-Trace: news04.bloor.is.net.cable.rogers.com 1064891615 24.192.11.167
(Mon, 29 Sep 2003 23:13:35 EDT)
| NNTP-Posting-Date: Mon, 29 Sep 2003 23:13:35 EDT
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!news-out.cwix.com!newsfeed.cwix.co
m!cyclone01.bloor.is.net.cable.rogers.com!news04.bloor.is.net.cable.rogers.c
om.POSTED!not-for-mail
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:53426
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| Do you know whether ownership of the HICON is taken over by the Bitmap
class
| when I do a Bitmap.FromHIcon or must I call DestroyIcon after creating a
| bitmap from the Icon? Is there anyway to tell that from the .NET
| documentation?
|
| Thanks again for your assistance, Tyler
|
|
| | > Tyler,
| >
| > >Is there a nice way in the .NET framework to load an icon resource that
| is
| > >embedded within a Win32 DLL?
| >
| > Not really, I think you have to call the ExtractIconEx Win32 API.
| >
| >
| >
| > Mattias
| >
| > --
| > Mattias Sjögren [MVP] mattias @ mvps.org
| > http://www.msjogren.net/dotnet/
| > Please reply only to the newsgroup.
|
|
|
 
T

Tyler

Thank-you very much for your assistance.

Tyler

Ying-Shen Yu said:
HiTtyler,
Thanks for using MSDN Newsgroup!
Bitmap class just uses the Icon handle, it will not take the ownership
of that handle, so you need
destroy it by yourself.
If you have any further questions on this issue, pleaset le me know.
Thanks!


Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!

--------------------
| From: "Tyler" <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| References: <[email protected]>
<[email protected]>
| Subject: Re: Loading Icon Resource from Win32 DLL
| Lines: 28
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <[email protected]>
| Date: Tue, 30 Sep 2003 03:13:35 GMT
| NNTP-Posting-Host: 24.192.11.167
| X-Complaints-To: (e-mail address removed)
| X-Trace: news04.bloor.is.net.cable.rogers.com 1064891615 24.192.11.167
(Mon, 29 Sep 2003 23:13:35 EDT)
| NNTP-Posting-Date: Mon, 29 Sep 2003 23:13:35 EDT
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!news-out.cwix.com!newsfeed.cwix.com!cyclone01.bloor.is.net.cable.rogers.com!news04.bloor.is.net.cable.rogers.c
om.POSTED!not-for-mail
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:53426
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| Do you know whether ownership of the HICON is taken over by the Bitmap
class
| when I do a Bitmap.FromHIcon or must I call DestroyIcon after creating a
| bitmap from the Icon? Is there anyway to tell that from the .NET
| documentation?
|
| Thanks again for your assistance, Tyler
|
|
| | > Tyler,
| >
| > >Is there a nice way in the .NET framework to load an icon resource that
| is
| > >embedded within a Win32 DLL?
| >
| > Not really, I think you have to call the ExtractIconEx Win32 API.
| >
| >
| >
| > Mattias
| >
| > --
| > Mattias Sjögren [MVP] mattias @ mvps.org
| > http://www.msjogren.net/dotnet/
| > Please reply only to the newsgroup.
|
|
|
 

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