Results 1 to 5 of 5

Thread: extract icons to flexgrid

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    Washington, DC
    Posts
    422

    extract icons to flexgrid

    I'm using the following API to pull icons from dll's and put them in a flexgrid. I want to insert the item into a cell in the flexgrid, and thought some db experts might have encountered this before. Any ideas?

    Thanks.

    Private Type SHFILEINFO
    hIcon As Long
    iIcon As Long
    dwAttributes As Long
    szDisplayName As String * 260
    szTypeName As String * 80
    End Type

    Private Declare Function SHGetFileInfo Lib "shell32.dll" Alias "SHGetFileInfoA" _
    (ByVal pszPath As String, ByVal dwFileAttributes As Long, psfi As SHFILEINFO, _
    ByVal cbSizeFileInfo As Long, ByVal uFlags As Long) As Long

    Private Declare Function ImageList_Draw Lib "comctl32.dll" _
    (ByVal himl&, ByVal i&, ByVal hDCDest&, ByVal x&, ByVal y&, ByVal flags&) As Long

    Private Sub Form_Load()
    Dim m As Long, ShInfo As SHFILEINFO

    m = SHGetFileInfo("C:\aim\aim.exe", 0&, ShInfo, Len(ShInfo), &H4000 Or &H1)

    If m <> 0 Then
    Picture1.AutoRedraw = True
    Call ImageList_Draw(m, ShInfo.iIcon, Picture1.hdc, 0, 0, &H1)
    End If
    End Sub

  2. #2
    Frenzied Member John McKernan's Avatar
    Join Date
    Jan 2002
    Location
    SE PA
    Posts
    1,295
    To insert a picture into a flexgrid cell:
    VB Code:
    1. With MSHFlaxGrid1
    2.     .Row = 1
    3.     .Col = 1
    4.     Set .CellPicture = LoadPicture(picturefile)
    5. End With
    You can also set the .CellPicture property using LoadResPicture to setting to an imagelist

  3. #3
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    ON, CAN
    Posts
    265
    hello,

    other than using John's method, you might have to subclass the Flexgrid and provide your own paint routine. For an exellent tutroial on subclassing, which also has an example of subclassing a flexgrid, go to

    ELITEVB.COM

    good luck.
    For excellent Winsock example check here WINSOCK

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Probably the easiest solution is to use those API calls to put the image into an invisible picturebox and then load it from there into the flexgrid. Once it's loaded into the flexgrid you can keep reusing the same picture.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    Washington, DC
    Posts
    422
    Thanks for the input. I'll play around with it and see what I can come up with.

    FLL

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