Results 1 to 3 of 3

Thread: LaVolpeImageList For form icons

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2016

    LaVolpeImageList For form icons

    How can I use this control? For example, I want to use an image in the image list as a form icon. Thank you.

    I test this:

    But the error is wrong: the type does not match

    Last edited by ChenLin; Jun 12th, 2019 at 01:37 PM.
    QQ: 289778005

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Beside Waldo

    Re: LaVolpeImageList For form icons

    Wow, that is an old, very old project I posted on PlanetSourceCode...

    Any way, that function returns an icon handle, not a stdPicture object. You will need to wrap the handle into a stdPicture object. Here's a routine that will do that. VB cannot display all 32bpp icons correctly. Just know that if the icon has alphablending.

    Sample call:

    hIcon = lvImageList1.ImageLists(1).Images.ExtractIcon(7)
    Set Me.Icon = zzHandleToStdPicture(hIcon, vbPicTypeIcon)

    Private Declare Function OleCreatePictureIndirect Lib "oleaut32.dll" (lpPictDesc As Any, riid As Any, ByVal fPictureOwnsHandle As Long, iPic As IPicture) As Long
    Private Function zzHandleToStdPicture(hImage As Long, imgType As PictureTypeConstants) As IPicture
        ' function creates a stdPicture object from an image handle (bitmap or icon used in this class)
        'Private Type PictDesc
        '    Size As Long
        '    Type As Long
        '    hHandle As Long
        '    lParam As Long       for bitmaps only: Palette handle
        '                         for WMF only: extentX (integer) & extentY (integer)
        '                         for EMF/ICON: not used
        'End Type
        Dim lpPictDesc(0 To 3) As Long, aGUID(0 To 3) As Long
        lpPictDesc(0) = 16&
        lpPictDesc(1) = imgType
        lpPictDesc(2) = hImage
        aGUID(0) = &H7BF80980   ' Picture GUID {7BF80981-BF32-101A-8BBB-00AA00300CAB}
        aGUID(1) = &H101ABF32
        aGUID(2) = &HAA00BB8B
        aGUID(3) = &HAB0C3000
        Call OleCreatePictureIndirect(lpPictDesc(0), aGUID(0), 1&, zzHandleToStdPicture)
    End Function
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online

    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2016

    Re: LaVolpeImageList For form icons

    Thank you LaVolpe, yes, it seems that only use 256 colors icon. This is what I found very good imagelist, who has a better recommendation?
    QQ: 289778005

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