The top-level base dialog that presents the Minimize/Maximize/Exit buttons is created with an IDL function called WIDGET_BASE. This function has a keyword syntax option "/TLB_KILL_REQUEST_EVENTS", which makes sure that your application is registered by the operating system to receive the event of a user pressing on the title bar's exit buttons. (By default such an event would bypass your application and go straight to the Operating System.)
When the event is sent to your application, your application's event handle for the top-level base can implement code like the following:
PRO my_app_event, event
if tag_names(event, /STRUCTURE_NAME) eq 'WIDGET_KILL_REQUEST' then begin
DO_SOME_LAST_MINUTE_PROCESSING, arg1, arg2
widget_control, event.top, /DESTROY
endif
END
It is up to you to run that last line "widget_control, event.top, /DESTROY" at some point. Once your app has registered to intercept the "kill request message" from the user, the O.S. will no longer get that message, and will no longer know to close the app unless YOUR code explicitly tells it to do so.
James Jones
|