I have my own class "AGE_ScrolledWindow", derived from wxScrolledWindow. Then there is an "Add" button. On click of this button, I add an instance of "wxCollapsiblePane". So, when the user clicks the "Add" button many times, several instances of "wxCollapsiblePane" are created.
When a new "wxCollapsiblePane" is added, scrollbar should go to the bottom, so that the newly added control is visible. I am achieving this through the "OnSize" handler of "AGE_ScrolledWindow", as below and it works fine.
Code: Select all
void AGE_ScrolledWindow::OnSize(wxSizeEvent& Event)
{
wxScrolledWindow::HandleOnSize(Event);
int r = GetScrollLines(wxVERTICAL);
SetScrollPos(wxVERTICAL, r);
Scroll(0, r);
Refresh();
Update();
}
However, what I do see is that if i open some other window (any random application), and then re-open my dialog box again, the view is correct. That is the repainting of window happens and then it shows the correct view (of the currently selected wxCollapsiblePane instance).
But, how can I achieve this repainting of the new scrolled position immediately (as soon as a wxCollapsiblePane instance is collapsed or expanded) ?
This is what I have written in handler for wxEVT_COLLAPSIBLEPANE_CHANGED event. But it is still not repainting immediately.
Code: Select all
void PropertiesDialog::OnMetaDataControlExpand(wxCollapsiblePaneEvent& event)
{
wxCollapsiblePane* p = dynamic_cast<wxCollapsiblePane*>(event.GetEventObject());
p->SetFocus();
wxPoint pt = p->GetPosition();
m_metaDataScrolledWindow->Scroll(0, pt.y/16);
m_metaDataScrolledWindow->SetScrollPos(wxVERTICAL, pt.y/16);
wxClientDC dc(m_metaDataScrolledWindow);
m_metaDataScrolledWindow->DoPrepareDC(dc);
p->Refresh();
p->Update();
m_metaDataScrolledWindow->Refresh();
m_metaDataScrolledWindow->Update();
RefreshRect(m_metaDataScrolledWindow->GetClientRect());
Update();
m_metaDataScrolledWindow->FitInside();
m_metaDataControlsbox->FitInside(m_metaDataScrolledWindow);
m_metaDataScrolledWindow->Refresh();
m_metaDataControlsbox->SetSizeHints(m_metaDataScrolledWindow);
m_metaDataControlsbox->Layout();
}