Ticket #15068 (closed enhancement: fixed)

Opened 3 months ago

Last modified 3 months ago

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

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

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

msw_artprov.patch download (9.2 KB) - added by markusj 3 months ago.

Change History

Changed 3 months ago by markusj

Changed 3 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.

Changed 3 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.

Changed 3 months ago by troelsk

  • cc troelsk@… added

Changed 3 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"?

Changed 3 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.

Changed 3 months ago by VZ

  • status changed from new to closed
  • resolution set to fixed

(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.