From: Lyle Johnson Date: 2002-12-06T09:16:37+09:00 Subject: Re: FXRuby question Rich Kilmer wrote: > Does anyone know how to capture the event generated when one clicks on > the X button in the upper right corner? I want to perform some > verifications and cleanup prior to closing. When you click the kill button on the main window, it (the FXMainWindow object) first sends a SEL_CLOSE message to its message target, if any. If that target handles the message then life goes on (i.e. the application doesn't shut down). If the main window doesn't have a message target, or if it does but the target doesn't handle the SEL_CLOSE message, then the main window sends a SEL_COMMAND message (with identifier FXApp::ID_QUIT) to the application (FXApp) object. And that more or less terminates the main FOX event loop. So for what you're describing, I think I'd try something like this: theMainWindow.connect(SEL_CLOSE) do # Do fun things verify_things clean_up_things if ok_to_quit? # All is well to shut down, so go ahead # and send the ID_QUIT message to the # application. theMainWindow.app.handle(theMainWindow, MKUINT(FXApp::ID_QUIT, SEL_COMMAND), nil) else # We've decided not to shut down after all end end Hope this helps, Lyle