Your code cannot work. In your DialogCanvas, you create buttons.
When clicking on one button, you erase the DialogCanvas (including
the button currently executing!!).
The functionality to try to implement is already implemented
via the Root browser.
To invoke the Root browser, simply do
TBrowser B;
Rene Brun
> Thanks in advance
> Hajo
>
> -------------------------------------------------------------------------
> // invoke main() after opening a root file with a directory structure
> //
> TDialogCanvas *dirCanvas;
>
> void doit(const char *dir)
> {
> gDirectory->cd(dir);
> drawdir();
> }
> void drawdir()
> {
> Coord_t ylow = 0.94;
> Coord_t yup = 0.99;
> Text_t cmd[40];
> TKey *key;
>
> dirCanvas->Clear();
>
> TList *lkeys = gDirectory->GetListOfKeys();
> TIter nextkey(lkeys);
> while (key = (TKey*)nextkey()) {
> printf("keyname %s\n",key->GetName());
> printf("classname %s\n",key->GetClassName());
> if (!strcmp(key->GetClassName(),"TDirectory")) {
> sprintf(cmd,"doit(\"%s\")",key->GetName());
> printf("keyname %s\n",key->GetTitle());
> TButton *button = new TButton(key->GetTitle(),cmd,0.2,ylow,0.95,yup);
> button->SetFillColor(10);
> button->SetTextAlign(12);
> button->Draw();
> yup += -0.05;
> ylow += -0.05;
> }
> }
> TButton *button = new TButton("back","doit("../")",0.5,0.1,0.6,0.2);
> button->SetFillColor(18);
> button->SetTextAlign(22);
> button->Draw();
> dirCanvas->Modified(kTRUE);
> dirCanvas->Update();
> dirCanvas->cd();
> }
>
> int main()
> {
>
> dirCanvas = new TDialogCanvas("dirCanvas","",400,200);
> dirCanvas->SetHighLightColor(2);
> dirCanvas->Range(0,0,1,1);
> dirCanvas->SetFillColor(10);
> dirCanvas->SetBorderSize(2);
> dirCanvas->SetDoubleBuffer(1);
> gDirectory->pwd();
> drawdir();
>
> }