ImageList->Handle

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dave Harris

    #1

    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_Destr oy(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<ImageLis t *> pImageList = new ImageList();

    Image* pvsBitmap = Image::FromHbit map(pBitmap->GetOSBitmap
    (), pBitmap->GetPalette() );
    pImageList->ImageSize = pvsBitmap->Size;
    int index = (int) pImageList->Images->Add(pvsBitma p,
    color);

    HIMAGELIST hImageList=(HIM AGELIST)pImageL ist-[color=blue]
    >Handle.ToInt32 ();[/color]
    // other code goes here.
    pImageList->Images->Clear();
    pvsBitmap->Dispose();
    //pImageList->Dispose();

Working...