Buttons inside frames

Hi

I used a button window example to create a gui.
With

[code] TGGroupFrame *Measurements = new TGGroupFrame(controls, “Measurement”);
Measurements->SetTitlePos(TGGroupFrame::kCenter);

Year = new TextMargin(Measurements, "Year");
Measurements->AddFrame(Year, new TGLayoutHints(kLHintsExpandX, 0, 0, 2, 2));
Year->SetEntry(2015);
Year->SetMinMax(1973,dateToday->GetYear());
Year->GetEntry()->Connect("TextChanged(char*)", "ButtonWindow",this, "SetYear(char*)");

Number = new TextMargin(Measurements, "Number");
Measurements->AddFrame(Number, new TGLayoutHints(kLHintsExpandX, 0, 0, 2, 2));
Number->GetEntry()->Connect("TextChanged(char*)", "ButtonWindow",this, "SetNumber(char*)");
Number->SetEntry(1);
Number->SetMinMax(1,65535);

AddM = new TGTextButton(controls, "Add");
Measurements->AddFrame(AddM, new TGLayoutHints(kLHintsBottom | kLHintsExpandX,0, 0, 0, 5));
//Add->Move(100,100);[/code]

I create controls as shown in the attached picture.
The last button I create apears outside the “Measurement” frame (below the “print” button).
Can anyone help what I am doing wrong here?

Cheers,
delos

Hi delos,

Hard to tell with the information you give… Could you provide a running macro showing the problem?

Cheers, Bertrand.

Hi bellenot

I attached the full macro. I hope it runs somehow since I am loading some measurement files right from the beginning.
And it is still a mess…

Thanks and cheers,
delos
probe2.C (13.8 KB)

Hi,

You must add the TGButton (or any child frame) to its parent composite frame (the one you pass as first argument in the TGButton constructor). So try:

AddM = new TGTextButton(controls, "Add"); controls->AddFrame(AddM, new TGLayoutHints(kLHintsBottom | kLHintsExpandX,0, 0, 0, 5));
Or:

AddM = new TGTextButton(Measurements, "Add"); Measurements->AddFrame(AddM, new TGLayoutHints(kLHintsBottom | kLHintsExpandX,0, 0, 0, 5));
Cheers, Bertrand.

Dear Bertrand

Thanks a lot.
I changed

to

Now it works. Should have realized myself, sorry.

Cheers,
delos