469,631 Members | 1,043 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,631 developers. It's quick & easy.

ImageList->Handle

We have a piece of code located in an unmanged C++
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();

Nov 15 '05 #1
0 1151

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by JaguarX | last post: by
2 posts views Thread by Bob C. | last post: by
6 posts views Thread by Udi | last post: by
1 post views Thread by Peter Larsen | last post: by
6 posts views Thread by [Joe] | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.