Re: Win32Lib Release resources

new topic     » goto parent     » topic index » view thread      » older message » newer message

Tommy Carlier wrote:
> 
> I know there's a attachCleanup-function where you can attach a cleanup
> routine, but
> that's only called when an error occurs. Is there also a similar function to
> attach
> a routine that is called when the application ends without errors, so that a
> library/application
> can release its resources?

Yes there is . Try including this in your library code.

 procedure Close_Screen(integer self, integer event, sequence parms)
    integer lRealId
    lRealId = getSelf()
    if lRealId = getId(w32GetMainWindow) then
      . . . Clean up code goes here . . .
    end if
 end procedure
 setHandler(Screen, w32HClose, routine_id("Close_Screen"))

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.

Hope this helps.
-- 
Derek Parnell
Melbourne, Australia

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu