I have made a root GUI application that inherits from a TransientFrame. I have put menu items on this frame. On the file menu, I have an exit button. The menu handler function calls a CloseWindow function within the class. Everything works except when I hit exit.
I also have a Dismiss button on the dialog that calls SendCloseMessage, this appears to exit fine.
Any suggestions on what I might be doing wrong?
The GUI application should inherit TGMainFrame. The TGTransientFrame class defines a transient windows that typically is used for a dialog that pops up over the application window.
Why do you use the TGTransientFrame instead TGMainFrame?
Thank you, Ilka
I am using a transient frame because functionally this is a dialog, however my thinking may be flawed. Can a main frame be a child of another main frame without difficulty?
Are menu bars not allowed with transient frames?
Well, As usual I didn’t know what I was doing and that caused the problem.
I was using the RQ_OBJECT macro in my dialog and it appears that my close window
function did not get registered.
I changed RQ_OBJECT in my class definition to ClassDef and then put a DontCallClose
call after the DeleteWindow.
I hope that this really does what I want and doesn’t cause memory leaks.
Just a few words as an answer of your questions:
The GUI classes, that ROOT provides, follow the main GUI design principles. According to them an application allows the user to prform a task. So called the application window is the primary window that has a title bar, a menu bar, maximize and minimize buttons. Optional components include a tool bar, a status bar, and a message bar. The TGMainFrame class is designed for this purpose.
The secondary window displayed in an application is called a dialog and it is used to gather information from the user or to display a message. The TGTransientFrame is developed for that. The menu bar contains a list of grouped commands for the application - it is better to have it in the application window, not in a dialog window. Anyway, because TGTransientFrame inherits TGMainFrame you can use it. There is no restriction and you can combine widgets in your GUI design as you wish according to the task you would like to perform.