1. Home
  2. Computing & Technology
  3. Delphi Programming
RTL reference|Glossary|Tips/Tricks|FREE App/VCL|Best'O'Net|Books|Link To
 
Windows Shell Extensions – Info Tip
Page 2: InfoTip – Introduction and Overview; Implementing Infotip Extensions
 More of this Feature
• Page 1: Shell extensions
• Page 3: Delphi project
 Join the Discussion
"Post your questions, concerns, views and comments to this article..."
Discuss!
 Related Resources
• Win/API articles
• COM/OLE articles

   InfoTip – Introduction and Overview
Infotip's are hint windows that pop up when the mouse hovers over any file. If an extension has not been registered for the file type a default Infotip appears (see Figure 1 for an example of this), but you can create your own extension to display any information you want for the specific file type. Office 2000 installs default handlers for MS Word and MS Excel that display the Name, Author and Title from the document properties. Infotip extensions differ from other shell extensions in its registration, we'll discover the differences later when we talk about registration of our Infotip extensions.

Info tip in Explorer

   Implementing Infotip Extensions
An Infotip Extension is an In-Process (Inproc) COM Server. This just means that it is a Windows DLL that exports the necessary methods to be a valid ActiveX control. Infotip Extensions also implement IQueryInfo and IPersistFile and must register itself into the registry. Because IQueryInfo and IPersistFile are interfaces, they don't contain code for their defined methods. It is required that our object implement every method defined in both of these interfaces; however, some of the methods are not necessary for our Infotip extension so we simply return E_NOTIMPL to indicate that these are not implemented.

IQueryInfo provides the text to display in the hint window and contains two methods:

  • GetInfoFlags – Retrieves the information flags for an item. Microsoft states that this is currently unused, so we return E_NOTIMPL.
  • GetInfoTip – Retrieves the text of the Infotip.

    GetInfoTip is defined as follows:

    function GetInfoTip(dwFlags: DWORD; var ppwszTip: PWideChar): HResult; stdcall;

    .dwFlags – currently not used
    .ppwszTip – Address of a Unicode string pointer that receives the tip string pointer.

    Important Note
    The ppwszTip parameter of the GetInfoTip method is a pointer to a Unicode string buffer that contains the text to display in the tip. This buffer must be allocated using the standard shell memory allocator because the buffer is allocated by our application, but freed by the shell. To ensure that everything happens in a thread-safe way, use SHGetMalloc to get the pointer to the shell's memory allocator – an object implementing IMalloc. Then, use IMalloc's Alloc method to allocate the memory needed to hold the Unicode representation of the Infotip text.
    The accompanying source code contains the standard code you will use for all Infotip Extensions you create. Simply use the same code and your extensions will be shell friendly and thread-safe.

    IPersistFile is what the shell uses to provide the extension with information about the file the user is hovering over. The interface defines five methods:

    .IsDirty – checks an object for changes since it was last saved to its current file. We don't need this for Infotip extensions so we return E_NOTIMPL.
    .Load – opens the specified file and initializes an object from the file contents. We use this method to retrieve the name of the file the user is hovering over.
    .Save – saves the object into the specified file. We don't use it, so return E_NOTIMPL.
    .SaveCompleted – notifies the object that it can revert from NoScribble mode to Normal mode. We don't use it, so return E_NOTIMPL.
    .GetCurFile – gets the current name of the file associated with the object. We don't use it, so return E_NOTIMPL.

    Load is defined as follows:

    function Load(pszFileName: PoleStr; dwMode: LongInt ): HResult; stdcall;

    .pszFileName – points to a zero-terminated string containing the absolute path of the file to open. .dwMode – specifies some combination of the values from the STGM enumeration to indicate the access mode to use when opening the file.

    We are only using the IPersistFile interface to obtain the path and filename of the file; we are not actually using the interface to access the file so we can ignore the flags. Our standard implementation of the Load method will be to store the contents of pszFileName to a private variable to be used by IQueryInfo::GetInfoTip to locate the file.

    Next page > Delphi project: Infotip; Registering Infotip Extensions > Page 1, 2, 3

  • All graphics (if any) in this feature created by Zarko Gajic.

     More Delphi
    · Learn another routine every day - RTL Quick Reference.
    · Download free source code applications and components.
    · Talk about Delphi Programming, real time.
    · Link to the Delphi Programming site from your Web pages.
    · Tutorials, articles, tech. tips by date: 2001|2000|1999|1998 or by TOPIC.
    · NEXT ARTICLE: New...Access Database from Delphi - DB/13.
    Chapter thirteen of the free Delphi Database Course for beginners. How to create an MS Access database without the MS Access. How to add an index to an existing table, how to join two tables and set up referential integrity. No MS Access, only Pure Delphi code.
     Stay informed with all new and interesting things about Delphi (for free).
    Subscribe to the Newsletter
    Name
    Email

     Got some code to share? Got a question? Need some help?
    Explore Delphi Programming
    About.com Special Features

    Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

    Easy ways to connect two computers for networking purposes. More >

    1. Home
    2. Computing & Technology
    3. Delphi Programming

    ©2009 About.com, a part of The New York Times Company.

    All rights reserved.