Hello,
The following is the basic idea of what my code is at the moment.
//Constructor
Classname::Classname(const TGWindow *p, UInt_t w, UInt_t h) : TGMainFrame(p, w, h)
{
TGDockableFrame *mainMenu = new TGDockableFrame(this);
AddFrame(mainMenu, new TGLayoutHints(kLHintsTop, 0, 0, 1, 0));
TGPopupMenu *fFileMenu = new TGPopupMenu(p);
TGMenuBar *fMenuBar = new TGMenuBar(mainMenu, 1, 1, kHorizontalFrame);
fMenuBar->AddPopup("&File", fFileMenu, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
mainMenu->AddFrame(fMenuBar, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
fFileMenu->AddEntry("Read System Configuration File", M_FILE_OPEN);
fFileMenu->AddEntry("&Exit", M_FILE_EXIT);
fFileMenu->Connect("Activated(Int_t)", "OPETSystemUI", this, "HandleMenu(Int_t)");
}
[code]
//HandleMenu(Int_t)
switch (id) {
case M_FILE_OPEN:
ConstructSys();
break;
case M_FILE_EXIT:
CloseWindow();
break;
}[/code]
[code]void Classname::ConstructSys()
{
static TString dir(".");
const char filetypes[] = { “All files”, "",
“ROOT files”, “.root",
“ROOT macros”, ".C”,
“Text files”, “*.[tT][xX][tT]”,
0, 0 };
ffi.fFileTypes = filetypes;
ffi.fIniDir = StrDup(dir);
printf(“fIniDir = %s\n”, ffi.fIniDir);
new TGFileDialog(gClient->GetRoot(), this, kFDOpen, &ffi);
printf(“Open file: %s (dir: %s)\n”, ffi.fFilename, ffi.fIniDir);
dir = ffi.fIniDir;
}[/code]
Where *ffi is a protected data member of type TGFileInfo.
So first I open my GUI main frame window and then open this TGFileDialog object to open a file. However, if I press Cancel or close the dialog box, the entire application window exits and not just the dialog box. I’m not sure what I’ve done wrong. I hope what the problem is is clear. If not, please let me know. Thanks.