#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

Description

Under Vista and higher, the code uses the Windows API function SHGetStockIconInfo to get native icons for the following wxArtIDs:
wxART_ERROR
wxART_QUESTION
wxART_WARNING
wxART_INFORMATION
wxART_HELP
wxART_FOLDER
wxART_FOLDER_OPEN
wxART_DELETE
wxART_FIND
wxART_HARDDISK
wxART_FLOPPY
wxART_CDROM
wxART_REMOVABLE

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:
wxART_HARDDISK
wxART_FLOPPY
wxART_CDROM
wxART_FOLDER
wxART_FOLDER_OPEN

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 19 months ago.

Download all attachments as: .zip

Change History (7)

Changed 19 months ago by markusj

comment:1 Changed 19 months 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 19 months 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 19 months ago by troelsk

  • Cc troelsk@… added

comment:4 Changed 19 months 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 19 months 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 19 months 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.