如何在Visual Basic 6中的Listview中获取附加到文件夹的文件夹图标

时间:2016-10-26 15:27:56

标签: vb6

如何将文件夹图标附加到ListView文件夹?这就是我的尝试:

Icons

Do While sFolderName <> ""
    For i = 0 To dirList.ListCount - 1  
    w = 1    
    hIcon = ExtractAssociatedIcon(App.hInstance, "C:\Windows", 3)
    If sFolderName <> "" And sFolderName <> "" Then
        If (GetAttr(sPath & sFolderName) And vbDirectory) = vbDirectory Then
            ListView2.ListItems.add , , sFolderName, Picture2.Picture
            Picture2.AutoRedraw = True
            Picture2.Cls
            DrawIcon Me.Picture2, 0, 0, hIcon
        End If

        'Tried the below same result
        If IsNull(hIcon) Then
            picBuff.Picture = Picture2.Picture
            'picDefault.Picture
        Else
            'Set picBuff.Picture = Picture2.Picture
            'Set picBuff.Picture = Nothing
            'DoEvents
            'picBuff.Picture = Picture2.Picture      
            'DrawIcon picBuff.hdc, 0, 0, hIcon
            'DoEvents
        End If
        sFolderName = Dir
    End If
    ...
Loop

(编辑:转换为易读的文字,虽然它只包含图片和代码。草本。)

0 个答案:

没有答案