Hmm, here is an idea:
- Generate a random number for each created PNG file, e.g. "845217623.png". This will prevent any writing access trouble.
- When the PNG is created, create the window and load the image. Store the loaded image's file name in a global object, indexed by the window's handle.
- When the window is destroyed, the file name is looked up from the global object and the image is deleted.
I think that'll work. I know it's not the most elegant solution, but I'll leave the challenge for you to play around with this idea.
As for finding out the position of the chat window, have a look at
GetWindowRect (user32). Create a
RECT memory structure using Interop.Allocate(), make the function fill it and use the data in the RECT structure to figure out where to place your window.
@matty: Okay, it'll work just fine with the time too. I don't know whether you want to delete those created images after closing the window, so I'll leave my comment untouched just in case.