472,334 Members | 1,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,334 software developers and data experts.

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 1209

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Terry | last post by:
There are a number of things about using unmanaged resources in Windows Forms programming that is unclear to me. In C++, if you loaded an icon...
1
by: JaguarX | last post by:
Hi, I made an application that displays a ListView that uses an Imagelist. I load the ImageList Control from a database I have no problems when...
2
by: Bob C. | last post by:
Hi All, I am using the ImageList/ListView Components to display around 100 images in C#.NET. The issue i have is, some times i may need to...
3
by: Grant Schenck | last post by:
Hello, I'm going round and round on how to best handle images for a treeview control. These are all known at design time so there is no dynamic...
2
by: Sanjeeva Reddy | last post by:
hai Anti Keskinen, i have used the following code MyListView->LargeImageList->ImageSize = gcnew System::Drawing::Size(100, 100); // Sets large...
0
by: Andre Viens | last post by:
Hello, I am using the following variation of code from <http://support.microsoft.com/default.aspx?scid=kb;EN-US;319340> to add icons to an...
6
by: Udi | last post by:
Hi, I have an imagelist initialized in design time with several icons files (.ico). However, when I need to extract an icon (Image) from the...
1
by: Peter Larsen | last post by:
Hi, How do i copy the images from handle to an instance of ImageList ?? This is what i have : Win32Ass.SHFILEINFO shinfo = new...
6
by: [Joe] | last post by:
Hi, How can I get the System class ImageList from C# application, I want to receive this image list used in device manager ? I find a C API : ...
2
by: prpradip | last post by:
In C#, Is it possible to get the exact handle of Icon which is inserted into ImageList from ImageList? Note: ImageList_GetIcon() returns not exact...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.