Results 1 to 9 of 9

Thread: File icons in a list view.

  1. #1

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  2. #2
    Lively Member
    Join Date
    Jan 1999
    Location
    México, D.F.
    Posts
    84

    Smile

    Thanks a lot Kedaman, I'm going to work with it.

    Regards.
    Angel Maldonado López.
    VB Programmer

  3. #3
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    If you want to display Icons for ALL file types, then use the ExtractAssociatedIcon() API, i.e.
    Code:
    Private Declare Function ExtractAssociatedIcon Lib "shell32.dll" Alias "ExtractAssociatedIconA" (ByVal hInst As Long, ByVal lpIconPath As String, lpiIcon As Long) As Long
    Private Declare Function DrawIconEx Lib "user32" (ByVal hdc As Long, ByVal xLeft As Long, ByVal yTop As Long, ByVal hIcon As Long, ByVal cxWidth As Long, ByVal cyWidth As Long, ByVal istepIfAniCur As Long, ByVal hbrFlickerFreeDraw As Long, ByVal diFlags As Long) As Long
    Private Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Long) As Long
    
    Private Sub Command1_Click()
        Dim lIcon As Long
        On Error GoTo User_Cancelled
        With CommonDialog1
            .CancelError = True
            .DialogTitle = "Select a File..."
            .Filter = "All Files (*.*)|*.*"
            .ShowOpen
            
            Picture1 = LoadPicture()
            Picture1.AutoRedraw = True
            lIcon = ExtractAssociatedIcon(App.hInstance, .FileName, -1)
            Call DrawIconEx(Picture1.hdc, 0, 0, lIcon, 32, 32, 0, 0, 3)
            Picture1 = Picture1.Image
            DestroyIcon lIcon
            
        End With
    User_Cancelled:
    End Sub

  4. #4

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    That's great, Aaron, youre always providing code!
    but i have a qwestion, what's the point with this:
    Picture1 = LoadPicture()
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    In my code I'm making the Icon I draw onto the Picturebox Persistent so you can't clear it using the Cls Method, using LoadPicture() loads an empty image into the Picturebox, effectively clearing it.

  6. #6

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Ok i see, i just wondered why you would need it to be persistent? Doesn't it drain more performance?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  7. #7
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    That depends on the size of the Image and what it's going to be used for.
    In my example I'm just displaying a single Icon in a Picturebox, so it's not hogging resources.
    Making it persistent is just something I've gotten into the habit of doing, as usually with these examples I get asked,
    "How can I stop the picture being erased when the Form/Picturebox is Repainted?".

  8. #8

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    But won't just using autoredraw solve that problem?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  9. #9
    Lively Member
    Join Date
    Jan 1999
    Location
    México, D.F.
    Posts
    84

    Thumbs up

    Hi Aaron:

    It works perfectly, thanks a lot to both.

    Best regards ! ! !
    Angel Maldonado López.
    VB Programmer

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