Re: Win32Lib Release resources
- Posted by Tommy Carlier <tommy.carlier at pandora.be> Jun 13, 2004
- 469 views
Derek Parnell wrote: > Each library (independant or otherwise) can insert this into their > code and expect it to get called when the Main Window is closed. Actually > it gets called whenever ANY window closes, so you have to detect when > it happens for the main window. That's why the getSelf() call is > there. > > setHandler() will create a chain of event handlers and call each one of > them when the event occurs. > > Note that this will be called prior to any application handler for the > w32HClose event on the Main Window itself. Thank you, but that doesn't really help: if you look at Win32Dib, you have to call finalizeDib() after you don't need Win32Dib anymore, to release memory allocated by the library. I've seen people forget this. That's why I want the library to do it automatically. If I use your technique, and I use getSelf() to get the window to be closed, there are 2 problems: 1. The w32HClose-event is called after this event, and it might still use Win32Dib-routines. finalizeDib() should be called after all bitmaps are removed (killDib()), preferably after WinMain(). 2. The library doesn't know what the main window is, so it can't compare it to getSelf(). Can't you just call the attachCleanup()-attached routines if the program ends? That would just do it, and I think it's logical: resources shouldn't only be released when an error occurs, but also when no error occurs. -- tommy online: http://users.pandora.be/tommycarlier