October 6th, 2010, 08:24 AM
I have a list box where i am customly drawing the objects in the listbox.Items collection to the screen using the DrawItem method. In each item, i am putting in a preview image, basically selecteditem.jpg for the sake of simplicity. If the user selects an item they have the ability to then press a button to create a new preview image. I had originally planned to create the new image with the same name as the original, but when i do that i get a file is open error. So my question is, is there a way to close any images that might be locked from the DrawItem Call so I can change the contents of that file, and then have the draw image come back through and pick it up. My current solution is to make temp jpg's with a number on the end of the file (somefile_tmp1.jpg, somefile_tmp2.jpg, ect. ect.) but the problem is this logic is greatly slowing down the program as it seems that the DrawItem method fires off 4 times each time you select one of the items in the listbox. If you scroll the list box, the draw item method fires any where from 8-11 times, which really makes it crawl. This can all be solved if i can just figure out how to overwrite the orginal file instead of all of this finding the next tmp jpg name i can use.
Thanks in advance.
Tags for this Thread
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!