[python-win32] Overlay Icon Question...

Tim Golden mail at timgolden.me.uk
Tue Apr 15 11:03:54 CEST 2008


Andrea Gavana wrote:
> Hi Roger,
> 
> On Tue, Apr 15, 2008 at 12:21 AM, Roger Upole wrote:
>> I've been meaning to look at how this works for some time,
>> so I took a few minutes to cook up an example (attached).
> 
> Thank you very much for the sample! It is really enlighting. I have
> however some difficulty to understand it (sorry for the dumb
> questions):

(I think Roger's in a different timezone, so I'll answer what
I can for the purposes of expediency. He can obviously speak
for himself when he's online).

You really want to look at:

http://msdn2.microsoft.com/en-us/library/bb776858(VS.85).aspx?topic=306117

for the inside story.

> 1) How do you actually use the SIOI class? 

As a class, you don't. It's simply the mechanism for serving the
COM object which contains the methods the shell will be calling 
back. There's some magic which the UseCommandLine call does
on your behalf to register the class as the COM server which the
shell expects.

> I tried to run the sample,
> then creating various files here and there in my hard drive, but I
> don't really know what IsMemberOf() is accepting as fname to make the
> overlay. Is it the file name? The icon name? Something else?

Find an icon file that exists, unless you happen to have something
on your J: drive which exactly matches Roger's example. I used the
TortoiseSVN icons on my machine under:

c:\Program Files\TortoiseSVN\icons\Classic\TortoiseAdded.ico

Replace the path in GetOverlayInfo with whatever you've chosen.
This is the icon which will be overlaid (in miniature) over whatever 
existing icon a file has.

Have the IsMemberOf method return S_OK for every file whose icon 
you want overlaid. The first param is the filename. Roger's example simply
looks for the world "overlay" in the filename.

> 2) Let's suppose that I want to assign an overlayed icon to a
> particular file in a directory: let's say this file is called
> "HELLO.DATA" and the directory contains also other files with the
> .DATA extension. What should I do to assign the overlayed icon only to
> this particular file?

Change the .IsMemberOf function to say something like:

if os.path.basename (fname) == "HELLO.DATA":
 return winerror.S_OK
return winerror.E_FAIL

Hope that helps

TJG


More information about the python-win32 mailing list