SftDirectory FAQs

How do I use the Filtering event with Visual C++?

Here is a sample in C++, which displays just disk drives:

void CFullTreeViewDlg::OnFilteringSftdirectory1(
                                 LPDISPATCH FAR* Folder,
                                 BOOL FAR* RemoveFolder)
{
    ISftDirectoryFolderPtr pFolder = *Folder;
    if (pFolder->GetType() >= typeSftDirectory_Computer_Drive35 &&
            pFolder->GetType() <= typeSftDirectory_Computer_Other) {
        ; // OK
    } else {
        *RemoveFolder = VARIANT_TRUE;
    }
}
What could the reason be for forms with SftDirectory loading slowly?

If a folder with invalid shortcuts is displayed, SftDirectory will seem to load slowly as the Windows Shell retrieves non-existent icon images for the invalid shortcuts. For example, if invalid shortcuts are present on the desktop, it may seem that forms load slowly. Removing the invalid shortcuts will correct the problem. These symptoms are only present if the Files property is set to True.

SftDirectory returns an empty Path property for the Desktop. How can I find the path for the Desktop?

The Desktop shown in the directory list is not the same as the Desktop directory. The physical location is usually something like C:\Documents and Settings\username\Desktop. The Desktop directory is a physical location with a path. You can retrieve its location using the Windows SHGetFolderPath API. The Desktop shown in the directory list is not a real location, it is a purely virtual folder. For that reason the Path property will always be empty (as there is no physical location). ItemIDList is also empty as it is not a locatable item. It is only shown for the SftDirectory styles (ControlStyle) styleSftDirectoryTreeView and styleSftDirectoryComboBoxTreeView. The Desktop is always the first item, making it easily recognizable by its position (its index is 0) or if you only have a folder object (SftDirectoryFolder) you can test it like this:

Dim AFolder As SftDirectoryFolder
Set AFolder = SftDirectory1.Selection(0) ' any folder
If AFolder Is SftDirectory1.FolderList(0) Then
    ... it's the Desktop
End If