Where to put "gApplication->Terminate(0);"?

Hi,

when we do GUI programming, according to tutorials, one can overwrite the function void Frame::CloseWindow() in order to catch the close signal from window manager and cleanly close the program by using gApplication->Terminate(0);. Like from tutorial:

void Frame::CloseWindow() { // Got close message for this MainFrame. Calls parent CloseWindow() // (which destroys the window) and terminate the application. // The close message is generated by the window manager when its close // window menu item is selected. TGMainFrame::CloseWindow(); gApplication->Terminate(0); }

Now, if you just simply plot something on the screen, ROOT throws an automatic (default) window. Where should one actually put the gApplication->Terminate(0); in this case? Is there a way to overwrite a function of a default windows/frames class?

Here is the short code where I plot a text file: https://github.com/xaratustrah/simplot/blob/master/simplot.cpp

cheers.
:mrgreen:

Hi,

You van use signal/slots. For example, in your code:

((TRootCanvas *)c->GetCanvasImp())->Connect("CloseWindow()", "TApplication", gApplication, "Terminate()");
Cheers, Bertrand.

works like a charm!

=D>

Many thanks.