Results 1 to 3 of 3

Thread: Need icons for ListView control

Hybrid View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2000
    Location
    Yugoslavia
    Posts
    16

    Post Need icons for ListView control

    How to get an icon (for .exe .ico .pif .lnk file) or to use default icon for the type of file requested and then to insert that icon in ListView control.

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    I don't fully understand you but tou can get icons by extracting them from files which contain them:
    Code:
    'This project needs a PictureBox, called 'Picture1'
    
    'In general section
    Private Declare Function DrawIcon Lib "user32" Alias "DrawIcon" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As Long
    Private Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long
    Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
    
    
    Private Sub Form_Load()
    Dim Path as String, strSave as string
        'Create a buffer string
        strSave = String(200, Chr$(0))
        'Get the windows directory and append '\REGEdit.exe' to it
        Path = Left$(strSave, GetWindowsDirectory(strSave, Len(strSave))) + "\REGEdit.exe"
        'No pictures
        Picture1.Picture = LoadPicture()
        'Set graphicmode to 'persistent
        Picture1.AutoRedraw = True
        'Extract the icon from REGEdit
        return1& = ExtractIcon(Me.hWnd, Path, 2)
        'Draw the icon on the form
        return2& = DrawIcon(Picture1.hdc, 0, 0, return1&)
    End Sub
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2000
    Location
    Yugoslavia
    Posts
    16
    What I want is to insert an icon that isn't in an ImageList into a ListView control, preferably an icon of a executable file or any other.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width