Redraw problems after removing frame

Hello,

I need to dynamically add and remove frames (in the attached example just labels) from a GUI window based on a combo box entry.

However, when I remove the frames and add new ones, the part of the old content is still drawn in the mother frame.

Exists there any method to refresh the window? I tried gClient->Redraw(), but this didn’t work.

Attached is a small example.
Click on the combo box at an entry smaller than ten, then the lower limit of the group frame still displays old content.

Thanks for you help!


Problem.C (3.03 KB)

Hi,

There is indeed a weird behavior… I’ll try to find where the problem comes from. But for the time being, you can try to use the following workaround:

[code]void MainFrame::UpdateOptions()
{

// manually hide and remove sub-frames
TGFrameElement *el;
TIter next(m_OptionsFrame->GetList());
while ((el = (TGFrameElement *) next())) {
m_OptionsFrame->HideFrame(el->fFrame);
m_OptionsFrame->RemoveFrame(el->fFrame);
delete el->fFrame;
}

for (int i = 0; i < m_Options->GetSelected(); ++i) {
TString Text("Added ");
Text += i+1;
Text += “/”;
Text += m_Options->GetSelected();
TGLabel* Label = new TGLabel(m_OptionsFrame, Text);
m_OptionsFrame->AddFrame(Label);
}

MapSubwindows();
// Give this element the default size of its content:
Resize(GetDefaultSize());
Layout();
MapWindow();
}[/code]
Note that I removed the extra composite frame m_OptionsSubFrame and changed a bit the original code.

Cheers, Bertrand.

Thanks, this workaround works nicely :smiley:

Btw, should I file it as an official bug report?

yes

Rene