How to resize Windows Icon Overlay?

2019-02-13 16:18发布

问题:

I made a icon overlay to my file, *.myfile, but the overlay size is wrong. When the icon shows in size 16x16, the overlay covers the icon.

How can I change the overlay size? (IShellIconOverlayIdentifier)

回答1:

You can't change the overlay size. Instead use a multi-resolution icon file where all necessary sizes are available.

For a good example take a look into the source of TortoiseSVN. Their will be only one icon file used, but if you open it with an appropiate paint tool, you'll see that this file contains different sizes.

Update

If you take a look right at the first method, you'll get the following comment:

"The Shell calls IShellIconOverlayIdentifier::GetOverlayInfo to request the location of the handler's icon overlay. The icon overlay handler returns the name of the file containing the overlay image, and its index within that file. The Shell then adds the icon overlay to the system image list."

You can see in line 129 that it tries to find out the path of the needed file from the registry. By browsing the code you can find the icons in subversion here. In line 165 you can see that it takes the filename from the registry and writes it back to its out parameters and maybe the magic flag to let windows decide which size should be taken from the file is *pdwFlags = ISIOI_ICONFILE;.