Add Ability to Set Shortcut overlays for icons

Summary

Id: 4089.17
Type: Issue Issue
Current Status: Open

Detail

6 Nov 2003 Open Eric Twose

Thanks a million for your excellent components - just the ticket! Though I was caching common file icons, my explorer application nearly choked when it came to displaying a large directory containing .ico icon files :).

Maybe you've worked this out already. Here's how I'm adding shortcut overlay images to the listview:

Whilst populating the listview from the system image list, keep a track of files with extension .lnk or .pif. Then:

If LinkCount > 0 then
    For n = 1 to lvwFiles.ListItems.Count
         Extension = lvwFiles.ListItems(n).SubItems(xyz)
         if Extension = "lnk" or Extension = "pif" then
             AddLinkOverlay(lvwFiles.hwnd,n)
         End if
         if n Mod 50 = 0 then DoEvents
    Next n
End if
 
Public Function AddLinkOverlay(ListViewHandle As Long, _
    ListViewItem As Integer)
 
    Dim LV As LV_ITEM
    Dim RetVal As Long
 
    With LV
        .item = ListViewItem
        .ubItem = 0
        .mask = LVIF_STATE 'or LVIF_IMAGE
        .state = 512
            'Shortcut overlay seems to be at index 1 in system image list.
            'IndexToOverlayMask(0+1) = 256, (1+1) = 512
            'Shift the index 8 bits left (index shl 8 in Delphi)
        .stateMask = LVIS_OVERLAYMASK
    End With
 
    RetVal = SendMessage(ListViewHandle, LVM_SETITEMSTATE, ListViewItem - 1,
LV)
 
End Function

Hope this is of use to you, Steve. Keep up the good work.