Extracting the SHELL icons under W2000 and WXP

Extracting the SHELL icons under W2000 and WXP

Post by Jiri Krivane » Sat, 05 Jul 2003 15:14:20



Hello,

I am having the following problem:

1. I receive the icon handle using the SHGetFileInfo() API.
2. I create the instance of the GDI+ bitmap class based on that icon handle.
3. Subsequently I use that bitmap for drawing to the GDI+ canvas.

Under Windows 2000 where the icons do not have any alpha-blending support,
everything works fine.

Under XP where the icons have the alpha-blending support, the final drawing
look crappy (especially the icon shadows look terrible). It seems, that the
alpha channel of the icon was damaged by the transfre from shell to my
application via SHGetFileInfo().

Any ideas would be appreciated.

Thank you,

Jiri.

The fragment of my (Delphi) code:

  SHGetFileInfo(
    PChar(AFile),
    0,
    BFI,
    SizeOf(BFI),
    SHGFI_ICON or SHGFI_LARGEICON or SHGFI_OPENICON
      or SHGFI_TYPENAME
  );
  BGpIcon := TGPBitmap.Create(BFI.hIcon);
  BGpGraphics.DrawImage(
    BGpIcon,
    MakeRect(0.0, 0.0, Skin.ImageSize, Skin.ImageSize),
    0.0, 0.0, BGpIcon.GetWidth, BGpIcon.GetHeight,
    UnitPixel
  );

 
 
 

Extracting the SHELL icons under W2000 and WXP

Post by David Lincol » Sat, 05 Jul 2003 18:19:40


Hi,

A quick test: does your executable include a "manifest" in its resources? Without a manifest, you can't draw alpha-blended icons.
Look up themeing and manifests in MSDN for more info.

Cheers,
Dave.

Hello,

I am having the following problem:

1. I receive the icon handle using the SHGetFileInfo() API.
2. I create the instance of the GDI+ bitmap class based on that icon handle.
3. Subsequently I use that bitmap for drawing to the GDI+ canvas.

Under Windows 2000 where the icons do not have any alpha-blending support,
everything works fine.

Under XP where the icons have the alpha-blending support, the final drawing
look crappy (especially the icon shadows look terrible). It seems, that the
alpha channel of the icon was damaged by the transfre from shell to my
application via SHGetFileInfo().

Any ideas would be appreciated.

Thank you,

Jiri.

The fragment of my (Delphi) code:

  SHGetFileInfo(
    PChar(AFile),
    0,
    BFI,
    SizeOf(BFI),
    SHGFI_ICON or SHGFI_LARGEICON or SHGFI_OPENICON
      or SHGFI_TYPENAME
  );
  BGpIcon := TGPBitmap.Create(BFI.hIcon);
  BGpGraphics.DrawImage(
    BGpIcon,
    MakeRect(0.0, 0.0, Skin.ImageSize, Skin.ImageSize),
    0.0, 0.0, BGpIcon.GetWidth, BGpIcon.GetHeight,
    UnitPixel
  );

 
 
 

Extracting the SHELL icons under W2000 and WXP

Post by Jiri Krivane » Sat, 05 Jul 2003 19:43:31


I tried the following...

The name of my executable is:
KkMenu.exe.

I created the file named:
KkMenu.exe.manifest,

having the following content:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
 <assemblyIdentity
  version="1.0.0.0"
  processorArchitecture="X86"
  name="Kk.KkMenu.KkMenu.exe"
  type="win32"
 />
 <description>Kk Menu for Stardock Object Dock.</description>
 <dependency>
  <dependentAssembly>
   <assemblyIdentity
    type="win32"
    name="Microsoft.Windows.Common-Controls"
    version="6.0.0.0"
    processorArchitecture="X86"
    publicKeyToken="6595b64144ccf1df"
    language="*"
   />
  </dependentAssembly>
 </dependency>
</assembly>

I placed the manifest file to the same directory, the KkMenu.exe is executed
in. MSDN says that this is equivalent to having the manifest in the
resources.

Result:

No change. The icons on Windows 2000 look normally but the shadows of the
Windows XP icons look terribly crappy.

Any other idea would be appreciated...

Thank you,

Jiri.

Quote:> Hi,

> A quick test: does your executable include a "manifest" in its resources?

Without a manifest, you can't draw alpha-blended icons.
Quote:> Look up themeing and manifests in MSDN for more info.

> Cheers,
> Dave.

 
 
 

Extracting the SHELL icons under W2000 and WXP

Post by Jiri Krivane » Sat, 05 Jul 2003 20:23:16


Hello,

I also tried to add the XP manifest into the program resources ... it
changed the visual look at WXP but did not affect the way icons are received
from the shell.

Now I really have no idea of how to achieve the improvement ...

Regards,

Kk.

Quote:> > Hi,

> > A quick test: does your executable include a "manifest" in its
resources?
> Without a manifest, you can't draw alpha-blended icons.
> > Look up themeing and manifests in MSDN for more info.

> > Cheers,
> > Dave.