Making Shell Popup ToolTips for File Items

For this article you require VC++ 6.0 or VC++ 5.0 with Internet Client SDK. Further Internet Explorer 4.0 or greater must be installed with Shell Integration.

You may have noticed that when mouse is placed over .doc files (shown in explorer or any where by shell) generated from Word 97 a tooltip showing the author name popups as shown in the screen shot below (The mouse pointer disappeared from the screen shot but it can be understood that it is over offer.doc)

The aim of this article is to show how this could be done for your file types. In particular I would show how this could be done for .cpp file popping out some useful information for the file.

How Shell Pops up a ToolTip

There was not much documentation available for how this could be done so nor any samples are available. All I knew was that Shell uses COM  for supporting all such extensions and such extensions can be implemented by implementing some interfaces and registering appropriate entries at appropriate places. In such a situation Regmon utility developed by Mark Russinovich and Bryce Cogswell came to rescue. You can download this utility from . It shows all the queries which are being done on registry by different applications.

All that I did was to start regmon to monitor all the Registry related calls from explorer.exe. I placed the mouse over a doc file and found out what is being queried in the registry. Soon it became clear that explorer queries for HKEY_CLASSES_ROOT\.doc\ShellEx\{00021500-0000-0000-C000-000000000046} and it creates an object of CLSID specified as the deafult value for this key. In this case it was {83799FE0-1F5A-11d1-95C7-00609797EA4F}. It was not hard to figure out that the registry entry was for a inproc-server of type "DocFile InfoTip Handler". The next step was to observe what are the interfaces supported by this object through OLEView.exe. Here is a screen shot of what OLEView showed.

Since IPersistFile is derived from IPersist it can be concluded that essentially "DocFile InfoTip Handler" implements IPersistFile and IQueryInfo. Luckily documentation for both these interfaces were available and soon it was clear how shell displays tooltips for files. Here is how it all happens :

  1. When mouse is placed over a file item (let's say file extension is .xxx) displayed in explorer. Shell queries for for the registry entry
  2. It then checks the default value present at this key. The value should be CLSID is string form of a COM class. If it is a valid value shell creates an object of that class.
  3. Once the object is created Shell queries for IPersistFile and calls the Load method of it passing the filename of the item over which mouse is placed. Obviously the intention is that that the object would find out information about the file show that it can display the tooltip.
  4. After that IQueryInfo is queried for and the method GetInfoTip is called. GetInfoTip has an out parameter *ppwszTip of type LPWSTR  which recieves the address of the tool tip buffer.
  5. Finally shell displays the tooltip.

With this much information in hand it was fairly trivial to develop an ATL project with an object implementing the interfaces.

The Sample Application

The sample application is an ATL project that implements these interfaces. To make it useful the sample pops up tooltips for .c, cpp, .h files. When the mouse is placed over any of these files shell creates the object. The application gets the first 256 characters of the file and checks whether it begins with '//' or '/*'. If it begins with '//' the first line of comment is displayed as a tooltip otherwise for C-Style comments the text before the comment ends (subject to 256 characters) is displayed as tooltip. Here is a screen shot:

Download demo project - 27 KB


  • Bug in Unicode builds

    Posted by Legacy on 08/30/1999 12:00am

    Originally posted by: Glenn Carr

    The comment doesn't work correctly in Unicode builds, because ReadFile tries to read
    Unicode from the file, when in fact it probably contains ANSI. The fix is to change the
    buffer that the file is read in to use 'char's instead of 'TCHAR's, and then convert it to
    a TCHAR's before/while passing it to GenerateInfoTip.

    char lpBuf[nMaxChar+1];

    if (!ReadFile(hFile, reinterpret_cast<LPVOID>(lpBuf), nMaxChar, &dwRead, NULL))
    return E_FAIL;

    lpBuf[nMaxChar] = 0;

    //Finally Close the File

    GenerateInfoTip( A2CT(lpBuf) );


  • Internet SDK and using VC 5

    Posted by Legacy on 05/01/1999 12:00am

    Originally posted by: Sam Hobbs

    I could not find the uninstalled version of the Internet SDK that I know I had somewhere, so I thought I would make it easy for myself by downloading it again from Microsoft. Microsoft has redesigned their web sites and other things so it was not clear what to download to get the Internet SDK. I finally decided to start by downloading the Platform SDK and I think it includes the Internet SDK.

    To make it easier for for others with VC 5 and without the Platform SDK etc., the file to download is iBLDENV.Exe. The size of it is 9,809KB.

    I still had a few compile errors (compiling using VC 5) even with the Platform SDK installed. I think they are the result of incompatibilities with VC 6. I made the following three simple changes to eliminate the compile errors:

    In infotip.cpp (the comment line is the old line):

    // _Module.Init(ObjectMap, hInstance, &LIBID_INFOTIPLib);
    _Module.Init(ObjectMap, hInstance);

    // return _Module.UnregisterServer(TRUE);
    return _Module.UnregisterServer();

    In InfoTipImpl.h (commented out the following):

    // ATLTRACE2(atlTraceCOM, 0, _T("IPersistImpl::GetClassID\n"));

  • Setting Info Tips

    Posted by Legacy on 04/14/1999 12:00am

    Originally posted by: Sam Hobbs

    What I would like to do is to be able to do the opposite of "GetInfoTip", in other words a "SetInfoTip" function for setting the Info Tips for a file. I thought I had found such a function and I had notes on what I found but I have lost the notes and now I cannot find whatever I had found. If I am right that such a function exists then it is elusive. Searching the MSDN for such things as "Info Tips" does not find anything.

  • Build error

    Posted by Legacy on 03/31/1999 12:00am

    Originally posted by: Octavio Paz

    hi ...

    i tried to build the infotip sample but i have the follow error: "error RC2135 : file not found: infotip.tlb"

    i hope that anybody can help me with that ...

    ps. i am using visual c++ 5.0 (SP3)

  • Build error

    Posted by Legacy on 03/31/1999 12:00am

    Originally posted by: Octavio Paz

    hi ...

    i tried to build the infotip sample but i have the follow error: "error RC2135 : file not found: infotip.tlb"

    i hope that anybody can help me with that ...

    ps. i am using visual c++ 5.0 (SP3)

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • As the mobile enterprise marketplace expands and customer needs grow more diverse, Samsung recognizes that solution partners and developers play an essential role by continually innovating to meet their customers' needs. Samsung works to provide these developers and partners with the latest tools and resources needed to create these solutions. Read this program guide to learn how the Samsung Enterprise Alliance Program provides partners and developers with Samsung enterprise software development kits (SDKs) …

  • Lenovo recommends Windows 8 Pro. "I dropped my laptop getting out of the taxi." This probably sounds familiar to most IT professionals. If your employees are traveling, you know their devices are in for a rough go. Whether it's a trip to the conference room or a convention out of town, any time equipment leaves a user's desk it is at risk of being put into harm's way. Stay connected at all times, whether at the office or on the go, with agile, durable, and flexible devices like the Lenovo® …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date