Get Icon info from the executable file? - windows

I'm trying to get the icon from the .exe file using the following APIs:
SHGetFileInfoW() SHGetImageList() and from the ImageList thus obtained I read the icon by calling GetIcon().
When the color depth of the machine is set to 32bit I get the 32bit color icon. The issue is when I change the machine's color depth to 24 or 16 bit then I get a 16bit color icon and this image seems to be corrupted.
I also checked for the list of available icons in some of the common windows applications (notepad, paint etc) and some of the office applications, none of had 16bit or 24 bit color icons.
What would be the best way to get the proper icons from the executable file ?
Thanks !

You can load exe's using LoadLibraryEx, and then extract the icons using LoadImage - or - if you want direct access to the icons data: FindResource, LoadResource, LockResource will give you a pointer to the icon's resources bits.

Related

Changing the size of fonts for dpi

Almost every source about Win32 dpi says that you need to load new scaled fonts.
I tested a simple application (main window and a child ListView, written in pure WinAPI) on WinXpSP3, Win7 and Win10 and in all cases the OS always automatically set the correct font size (and even non-client areas) both at startup and when changing the system scaling in runtime. The only thing I had to change manually was the size of the windows themselves and the size of the icons in the ListView.
The application manifest contained
dpiAware True/PM
dpiAwareness PerMonitorV2, PerMonitor
And I'm a little confused. It turns out that manual processing of fonts is needed only for owner-drawn controls?

XP Popup Menu Icons not Transparent when highlighted

I know XP is old, but I just have to know the issue here.
I don't see a way to provide a popup menu with anything like an icon or bitmap with a mask, only a bitmap. So, if I use a compatible bitmap, it will look transparent when the selection bar is not highlighting it, but when highlighted the entire graphic still shows (with a square button face color around it).
If I use a 32bit DIB with alpha, the transparent item just shows black (whereas Windows 10 handles the transparency fine - I presume Vista and Win7 would, too).
If I manually set all the A's to 0 in the DIB, it is still black (on Win10, the images where color would normally be appear white - I would have thought it would be transparent).
Anyway, was there ever a way to provide an icon (since it has a mask), or a bitmap with mask, to a menu so things like XP can handle it automatically (no owner draw)?
Is there a way to force loading of an .ICO file to be the 256 color version instead of the 32bit RGB/A version? I don't have a 24bit RGB graphic in the .ICO, so maybe XP would pick that if it existed instead?
I know GDI doesn't support alpha in all cases, but sometimes it does, and it appears the Windows version matters as well.
Does someone have a background on this, and can tell if this is a known XP issue with 32bit bitmaps?
On XP you must custom draw but not the entire thing, just the bitmap/icon.
On Windows 95/NT4 the only way to do this properly is to custom draw the entire menu item. Before Vista the menu look only changed once, the addition of flat menus in XP, so custom draw everything is certainly possible.
Some time around Windows 98/2000 the ability to set MENUITEMINFO.hbmpItem to HBMMENU_CALLBACK was added. Use DrawIconEx or a image list.
Vista added support for 32bit ARGB bitmaps. You should not use the callback method here because that will disable the new visual style.
See also:
Themed menu’s icons, a complete Vista and XP solution
MSJ cool custom draw

Some icons display differently VB6

I have a VB6 application which is running under Windows 10 with admin rights. The application is made up of various things but the main form (frmMain) has several buttons with icons on it. Each of the icon files used is a 32x32 ico file and the majority display as they have always done. I am finding though that about 40% are showing differently - mainly quite big and blocky. I can't figure out any difference in the properties of the buttons they are associated or the files so why do some change and some don't?
Maybe your icons use a different color depth or if they are loaded at runtime they are stored in different ImageLists?

exe icon is not full size (windows 10)

I want to set an icon for my program (exe file and desktop shortcut). I am using Qt 5.7 on Windows.
I followed the instructions from: http://doc.qt.io/qt-5/appicon.html, that is in the pro file I put "RC_ICONS = logo7.ico".
When I install the program on my computer (Win8), it works well. The desktop shortcut's icon shows my logo perfectly and full size. However, when I install the program on another computer (Win10), the desktop shortcut's icon is not full size. Even if I CTRL-scroll on the desktop to change the icon size, this icon remains the same size.
Here is an example of two desktop icons (one full and the other one that does not scale).
image here
Is there something special I should do with my icon (I tried icon sizes of 128x128 to 512x512) so that its full screen ?
Or is it something to do in Qt ?
Thank you so much !
Alex
Most windows 10 .ico icons are multi layer files instead of them being truly scalable. Akin to animated gifs but no animation, just layers. Open a .ico file in Gimp Image editor, you'll see the different sizes in layers. Here is a quick link to the Windows Media center icon hosted on icon archive: http://www.iconarchive.com/show/mega-pack-2-icons-by-ncrow/Windows-Media-Center-icon.html
attached is a screen shot of what I am talking about:
screen shot of windows media player icon
you could use it as a template and replace their pic with yours

How many pixels in the Windows Taskbar Icons?

I'm making a program that will show you when caps lock is turned on. I want it to display a little icon on the Windows Taskbar by the icons such as the battery, volume and internet connection. I was just wondering what the dimensions of the image could/should be.
Googling on this...
windows tray icons resolution
... the first few hits are quite helpful; What is the size of the icons in the system tray? says that
It's 16x16. If you create a .ico file that supports 16, 32, 48 and 256 sizes, you're covered.
And it points here, where Microsoft recommends:
Notification area icons should be high-DPI aware. An application should provide both a 16x16 pixel icon and a 32x32 icon in its resource file, and then use LoadIconMetric to ensure that the correct icon is loaded and scaled appropriately.

Resources