The Project

We start by adding a class called clsQueryInfo to the RadEx project. The class implements IQueryInfo and IPersistFile. Example 10.2 is the project listing. It’s really short, so let’s walk through the whole thing.

Example 10-2. Project Listing

'clsQueryInfo.cls

Implements IPersistFile
Implements IQueryInfo

Private m_sFile As String

Private Sub IPersistFile_Load(
    ByVal pszFileName As VBShellLib.LPCOLESTR, _ 
    ByVal dwMode As VBShellLib.DWORD)

    m_sFile = Space(255)
    CopyMemory ByVal StrPtr(m_sFile), ByVal pszFileName, Len(m_sFile)
    
End Sub

Private Sub IQueryInfo_GetInfoTip(
    ByVal dwFlags As VBShellLib.DWORD, _ 
    ppwszTip As VBShellLib.LPWSTRVB)
    
    Dim b(  ) As Byte
    
    Dim sTemp As String
    sTemp = Space(255)
    
    Dim sMsg As String
    
    GetPrivateProfileString "Animal", _
                            "Type", _
                            "Unknown", _
                            sTemp, _
                            Len(sTemp), _
                            m_sFile
                                 
    
    sMsg = "Type: " & sTemp & vbCrLf
    
    ppwszTip = StrPtr(sMsg)
 
End Sub

First, let’s get IPersistFile::Load out of the way. This should be very familiar to you, since we have already implemented Load for icon handlers, drop handlers, and data handlers. InfoTip handlers are no different: we simply copy the name of the selected file, which is passed to the Load method in the pszFileName argument, to a local variable, m_sFile.

To complete the implementation of IPersistFile, you can just add the following line of code for the remainder of the methods:

Err.Raise E_NOTIMPL

After you have implemented the remaining methods of IPersistFile, we can begin implementing IQueryInfo. And for once, ...

Get VB Shell Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.