Standalone TBrowser

Hello,
I write you there to figure out if someone could actually help me in this task.
For a wider project I wrote some code and the result is stored in a .root file.
In order to make this kind of file “browseable” by people who doesn’t have ROOT installed I am now working on a little .cpp from which execution I plan to obtain a running TBrowser.

#include <TROOT.h>
#include <TBrowser.h>
#include <TApplication.h>

void main(){
	TApplication app("myapp",0,0);
	TBrowser* t=new TBrowser();	   
	app.Run();
}

this works already but I have two issues:
1- I get an error inside the TApplication "Error in TWinNTSystem::BaseName: name=0. Even if I know it might be a very Windows-specific error maybe you could suggest me how to simply hide this error.
2- I would like the application to start hidden or I would like the prompt to close on TBrowser close button click.

Thanks, any help would be appreciated!

Gabriele

Hi Gabriele,

Here is a simple example:

[code]
#include “TApplication.h”
#include “TSystem.h”
#include “TFile.h”
#include “TBrowser.h”

class RBrowser : public TBrowser {
public:
RBrowser() : TBrowser() {}
virtual ~RBrowser() { gApplication->Terminate(); }
};

int main(int argc, char **argv)
{
TFile *f[256];
gSystem->Load(“libTreeViewer”);
gSystem->Load(“libGeom”);
if(argc > 1) {
for(int i=1;i<argc;i++)
f[i] = TFile::Open( argv[i], “READ” );
}
TApplication theApp(“rbrowser”, &argc, argv);
new RBrowser();
theApp.Run();
return 0;
}[/code]
And add: -SUBSYSTEM:WINDOWS -ENTRY:mainCRTStartup in the linker flags, to prevent the command prompt to show-up

Cheers, Bertrand.

Awesome solution to send the TApplication::terminate() on the TBrowser destruction.
I’ll feedback you in a while.

Thanks a lot Bertrand

Gabriele

EDIT: the error was linked to the missing (&argc,argv) in TApplication constructor. No need to add any new flag. Thanks again!