function that is currently bleeding a GDI each time it is
run. We have tried numerous things, each with its own
problems.
We made pImageList a static (and threw it in a gcroot)
and commented out the dispose because the system would
crash or hang after a few hundered iterations (we could
place a for loop around this very block and crash after a
while. The static saves it from crashing after a few
hundred, but we have the bleed now - which is especially
bad news for Win98
We attempted to call ImageList_Destroy(hImageList)
after. This ruins the managed pImageList if static, and
is ineffectual if not static.
Making hImageList static simply doesn't work. It appears
that hImageList is different each time through, which is
curious if ImageList is the same each time. If we get
the handle before adding the bitmap we bleed profusely
both memory and GDI's
What are we missing here? There are no bleeds or crashes
so long as we done call the ->Handle property. After
that, its like we have two handles ointing to the same
thing, and we can't clean up both.
Any help appreciated.
static gcroot<ImageList *> pImageList = new ImageList();
Image* pvsBitmap = Image::FromHbitmap(pBitmap->GetOSBitmap
(), pBitmap->GetPalette());
pImageList->ImageSize = pvsBitmap->Size;
int index = (int) pImageList->Images->Add(pvsBitmap,
color);
HIMAGELIST hImageList=(HIMAGELIST)pImageList-
Handle.ToInt32();
// other code goes here.
pImageList->Images->Clear();
pvsBitmap->Dispose();
//pImageList->Dispose();