Hi,
TGCanvas is not an owner of the canvas container, i.e.
container is not a subframe of scrolled canvas.
Container frame must be deleted (probably this case is badly docunmented).
The following code should help :
/// v.o. ///// canvas container frame ////////
static TGCompositeFrame *TBFrame;
EntryTestDlg::EntryTestDlg(const TGWindow * p, const TGWindow * main)
: TGTransientFrame(p, main, 10, 10, kHorizontalFrame)
{
Int_t i,N;
TGLabel *tglabel;
char txt[32];
TGNumberEntry *tne[2];
TGCheckButton *cb;
// use hierarchical cleani
SetCleanup(kDeepCleanup);
/*********************************************************************/
EditList = new TList();
N = 10;
TGCanvas *fCanvasWindow = new TGCanvas(this, 400, 600);
TBFrame = new TGCompositeFrame(fCanvasWindow->GetViewPort(),
10,10, kHorizontalFrame);
fCanvasWindow->SetContainer(TBFrame);
//// v.o. - automatically delete all subframes of canvas container frame
TBFrame->SetCleanup(kDeepCleanup);
/*
* N+1 Rows since we have a label header first in the
* scrolled window.
*/
TBFrame->SetLayoutManager(new TGMatrixLayout(TBFrame, N+1, 4, 2));
tglabel = new TGLabel(TBFrame, new TGHotString("ID"));
TBFrame->AddFrame(tglabel);
tglabel = new TGLabel(TBFrame, new TGHotString("Depth"));
TBFrame->AddFrame(tglabel);
tglabel = new TGLabel(TBFrame, new TGHotString("Speed"));
TBFrame->AddFrame(tglabel);
tglabel = new TGLabel(TBFrame, new TGHotString("Mark"));
TBFrame->AddFrame(tglabel);
for (i=0; i <N>AddFrame(tglabel);
tne[0] = new TGNumberEntry(TBFrame,
500, 8, i,
TGNumberFormat::kNESRealOne,
TGNumberFormat::kNEAAnyNumber,
TGNumberFormat::kNELLimitMinMax,
0.0,
50000.0);
TBFrame->AddFrame(tne[0]);
tne[1] = new TGNumberEntry(TBFrame,
1500, 8, i+1000,
TGNumberFormat::kNESRealOne,
TGNumberFormat::kNEAPositive,
TGNumberFormat::kNELLimitMinMax,
1000.0,
1600.0);
TBFrame->AddFrame(tne[1]);
// Put in checkbox for indicating deletion.
cb = new TGCheckButton (TBFrame, new TGHotString("Delete"));
TBFrame->AddFrame(cb);
EditList->Add(new PointTracker(i, tne, cb));
}
TBFrame->Resize();
AddFrame(fCanvasWindow, new TGLayoutHints(kLHintsRight,
2, 2, 2, 2));
/****************************************************************************/
// set dialog box title
SetWindowName("Number Entry Test");
SetIconName("Number Entry Test");
SetClassHints("NumberEntryDlg", "NumberEntryDlg");
// resize & move to center
MapSubwindows();
UInt_t width = GetDefaultWidth();
UInt_t height = GetDefaultHeight();
Resize(width, height);
CenterOnParent();
// make the message box non-resizable
SetWMSize(width, height);
SetWMSizeHints(width, height, width, height, 0, 0);
SetMWMHints(kMWMDecorAll | kMWMDecorResizeH | kMWMDecorMaximize |
kMWMDecorMinimize | kMWMDecorMenu,
kMWMFuncAll | kMWMFuncResize | kMWMFuncMaximize |
kMWMFuncMinimize, kMWMInputModeless);
MapWindow();
fClient->WaitFor(this);
}
EntryTestDlg::~EntryTestDlg()
{
// dtor
delete EditList;
////// v.o. ////////////delete container frame
delete TBFrame;
}