Opened 5 years ago

Closed 5 years ago

#15068 closed enhancement (fixed)

[MSW] Extend wxArtProvider to return native icons for some wxArtIDs

Reported by: markusj Owned by:
Priority: normal Milestone:
Component: wxMSW Version: stable-latest
Keywords: wxArtProvider Cc: troelsk@…
Blocked By: Blocking:
Patch: yes


Under Vista and higher, the code uses the Windows API function SHGetStockIconInfo to get native icons for the following wxArtIDs:

If this is not available, it uses wxFSVolume to get a list of volumes and if a matching kind is found, it uses the Windows API function SHGetFileInfo to get an icon for the following wxArtIDs:

If that fails, the code tries to get an icon directly from the SHELL32.DLL in the Windows system directory. This assumes that the icon indices for lower values are identical for all different versions of this DLL.

Attachments (1)

msw_artprov.patch download (9.2 KB) - added by markusj 5 years ago.

Download all attachments as: .zip

Change History (7)

Changed 5 years ago by markusj

comment:1 Changed 5 years ago by catalin

AFAIK SHGetStockIconInfo gets the icons from imageres.dll
FWIW here are is a list of files that contain icons under Win7
For other files finding the indexes could be a problem though, here they are for the first 238 icons in shell32.dll (Win 7 has some more icons after those). No idea about the rest of the files.

comment:2 Changed 5 years ago by markusj

The icon index problem only refers to the last step using SHELL32.DLL. All other icons are retrieved through officially documented API functions.

comment:3 Changed 5 years ago by troelsk

  • Cc troelsk@… added

comment:4 Changed 5 years ago by vadz

I'm not sure if it's a good idea to use hardcoded shell32.dll icon indices like this, especially considering that we only do it for the icons that are normally retrieved using the APIs above anyhow. So I'll probably apply this patch without this "last resort" part, unless I'm missing something.

P.S. How should I credit you in our changes file? Just "Markus"?

comment:5 Changed 5 years ago by markusj

Without the shell32.dll part, on pre-Vista systems you'll get icons for floppy, cdrom, removable drive only, if such a kind is currently present on the machine.

You can credit me as "markus juergens". thanks.

comment:6 Changed 5 years ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [73593]) Use more native icons in wxMSW wxArtProvider.

Use SHGetStockIconInfo() and SHGetFileInfo() to look up some icons.

Closes #15068.

Note: See TracTickets for help on using tickets.