#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2009
    Posts
    1
    Rep Power
    0

    Code not working - ExtractIcon leaks


    Hi Guys,

    I am trying to place an Icon on VSFlexgrid cell (using ImageList). Below is the code sample for it:
    Dim mImageList as ImageList
    Dim hIcon As Long
    hIcon = mImageList.ListImages(1).ExtractIcon
    mGrid.Cell(flexcpPicture, key) = hIcon

    This ExtractIcon on ListImage leaks as it always creates a new instance. When I try to destroy the icon using DestroyIcon it removes the GDI leak but also removes the icon from the flexgrid. So I don't see any icon. Below is the sample code:

    Dim mImageList as ImageList
    Dim hIcon As Long
    hIcon = mImageList.ListImages(1).ExtractIcon
    mGrid.Cell(flexcpPicture, key) = hIcon

    DestroyIcon hIcon

    So I thought converting this Icon to StdPicture and then place it on flexgrid. In that way I can destroy the icon and use the picture on the cell.

    Dim mImageList as ImageList
    Dim hIcon As Long
    Dim pic As New StdPicture
    hIcon = mImageList.ListImages(Status).ExtractIcon
    Set pic = ConvertIconToHandle(hIcon)
    mGrid.Cell(flexcpPicture, mGrid.FindRow(mstrKey)) = pic

    DestroyIcon hIcon

    So there is no leak with StdPicture but I still can't see any icon on flexgrid. Any help will be appreciated.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2011
    Posts
    13
    Rep Power
    0
    try deleaker or similar debugger for GDI leaks...
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2011
    Posts
    13
    Rep Power
    0
    I think you've already decided your problem

IMN logo majestic logo threadwatch logo seochat tools logo