
December 14th, 2009, 05:25 AM
|
|
Registered User
|
|
Join Date: Dec 2009
Posts: 1
Time spent in forums: 4 m 3 sec
Reputation 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.
|