Checking existence of a TGMainFrame object

Hi everyone,
I have a GUI (ROOT based) interface to my program and I would like to check if it has been killed using the “X” button of the window instead of closing it properly via an “exit” button.
I know I can check, for example, the existence of a TCanvas object using

 gROOT->GetListOfCanvases()->FindObject(myCanvas)

Does anybody know how it is possible to check the existence of a TGMainFrame?
Thanks!
Emiliano

Hi Emiliano,

There is no list of TGMainFrames in Root, but you can use the CloseWindow() signal emitted when user close the window by the “X” button of the window.
You can also use TGMainFrame::DontCallClose() to handle yourself the destruction of your TGMainFrame.

Cheers,
Bertrand.

Hi Bertrand,
thanks for your help!
I have tried both your suggestion and I have some problems with the “CloseWindow()” signal, while the DontCallClose option works fine (and it’s what I need).
Anyway it could be interesting to know why I cannot connect the action of clicking on the “X” to the closewindow signal. Attached you will find a small working example of what I am trying to do. If I start root and run .x mygui.C when I click on the “x” of the window the window is killed but the slot “dontcloseme” is not called, what I am doing wrong?
On the other hand when the loop ends the window is correctly closed by my call to “myClosing” routine…
If you uncomment “DontCallClose()” and you comment the “connect” line you’ll see that the “X” of the window is correctly disabled.
Thanks again for your help!
Cheers,
Emiliano
mygui.C (1.35 KB)

Just for completeness, I am using ROOT Version 4.03/02 on a LInux i686 machine (SL 3.0.5).
Cheers,
Emiliano

Hi Emiliano,

Take a look at your modified code in attachment :wink:
Since your class inherits from TGMainFrame, which is already a TQObject, no need to specify RQ_OBJECT(“MyMainFrame”);
It works with version 5.10.00 on Win32.
Plese let me know if you still have trouble.

Cheers,
Bertrand.
mygui.C (1.37 KB)

It works, thanks!
Emiliano