I want to display PNG or ICO extracted from a resouce dll file...but i don't know how
...HOW CAN I DISPLAY 48x48,64x64 ICON WITH TRUE COLOR ... AND PNG...??
I build a resource.dll and sample here: http://www.mediafire.com/?c5gm08b11unr0t7 (Or in attachement)
...containing 32x32,48x48,64x64 icon( 256 and True Color) and PNG file.
The simplest method is to use ExtractIconEx API to retrieve a handle and use DrawIconEx to draw it. But it won't work for PNG on XP and lower. And on Win2K and lower, 32bpp icons will look bad.
Otherwise, getting images from an external DLL, EXE, OCX requires some code & many examples exist on the net. Here is one from theVBZone. Scroll towards very bottom.
The problem you will have is that you won't know which are 48x48 and which are PNG without parsing the data. Though one can use the CreateIconFromResourceEx API (I've provided sample usage on this link) and DrawIconEx API to draw it to a window, it won't work if the icon is a PNG unless you are running Vista or better; otherwise it will work for PNGs.
Another option is to look at my "Icon Organizer/Extractor" project linked in my signature below. Specifically within that project look at the ProcessExeDLL function in frmIcon. It shows how I displayed the icons on the form. Initially, you'll want to run the project, press Ctrl+E, then select your DLL. It should display the icons correctly.
Last edited by LaVolpe; Feb 16th, 2011 at 11:32 AM.
Insomnia is just a byproduct of, "It can't be done"
Since it is a valid Windows resources file (shown below are the ICO/PNG images extracted therefrom), just call LoadLibraryEx and EnumResourceTypes etc.
Remarks: Some IDE entries for PNG items appear to be erroneous, though this would not affect the correct display of PNG images.
Last edited by petersen; Feb 16th, 2011 at 05:19 PM.
Reason: Added remarks.
LaVolpe
Your Icon Organizer/Extractor is exactly what i want ( I need to display PNG file extracted from external resource dll on a form in WinXP,Vista,Win7)...But your code is complex for me...I need a small sample code to do this (extract PNG or ICO and display)
All I can do is suggest you spend a little time with that one function I mentioned. Try to understand it. There is stuff in there you won't need to worry about. Specifically, I a temp file to store extracted image data which won't apply in your situation. But the finding and extraction from the resource you'll want and also parsing of the data to determine the size and whether or not a PNG or icon format.
Insomnia is just a byproduct of, "It can't be done"