GUI - Problems

Hello everyone,
I’m trying to write a little GUI based on the root- TG*-classes under Visual Studio c++ 2008. Now i’m trying to open a TGFileDialog to get a filename (see below). When doing this it produces an Unhandled exception
as soon as it tries to invoke:
virtual void MapRaised() { gVirtualX->MapRaised(fId); }
I’m not really getting why this is happening as though i have to admit i’m quite a beginner with GUI-Applications.

Thank you much for your help in advance

void MainWindow::openFile()
//Type for the files allowed
const char filetypes[] = {".lma"};

//Initial directory
TString directory(“C:\temp\”);

TGFileInfo file_info;
file_info.fFileTypes = filetypes;
file_info.fIniDir = StrDup(directory);

//Open the dialox box
fd = new TGFileDialog(gClient->GetRoot(), this, kFDOpen, &file_info);

Peakfinding 2.0.rar (1.76 MB)

Hi Moritz,

I didn’t try your code yet, but please replace: const char *filetypes[] = {"*.lma"}; By: const char *filetypes[] = {"lma files", "*.lma", 0, 0};
The filetypes should contain the description of the files (e.g. “lma files”) and the extension ("*.lma"). Then the 0 are used to mark the end of the arrays.


And there you already solved my problem.
Thank you very much for the quick response.
Cheers Moritz

You’re most welcome :slight_smile:
Cheers, Bertrand.