From 2881d9875ad6fdbdfbb564b7bfdc27dfcec1e72f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Mar 2018 22:29:13 +0100 Subject: [PATCH] Fix recently broken (re-)layout in the listctrl sample This completes changes of 0873abb836582db1908e8bec185897ae2da0ca50 which replaced manual layout code with sizers, but broke layout after recreating the control in the process. This change notably fixes the control becoming invisible, due to having the default too small size, in non-report modes. --- samples/listctrl/listtest.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/samples/listctrl/listtest.cpp b/samples/listctrl/listtest.cpp index 6eb4eb4544..84d6898b04 100644 --- a/samples/listctrl/listtest.cpp +++ b/samples/listctrl/listtest.cpp @@ -110,8 +110,6 @@ bool MyApp::OnInit() // ---------------------------------------------------------------------------- wxBEGIN_EVENT_TABLE(MyFrame, wxFrame) - EVT_SIZE(MyFrame::OnSize) - EVT_MENU(LIST_QUIT, MyFrame::OnQuit) EVT_MENU(LIST_ABOUT, MyFrame::OnAbout) EVT_MENU(LIST_LIST_VIEW, MyFrame::OnListView) @@ -449,13 +447,23 @@ void MyFrame::RecreateList(long flags, bool withText) (m_listCtrl->GetWindowStyleFlag() & wxLC_VIRTUAL)) ) #endif { - delete m_listCtrl; + wxListCtrl* const old = m_listCtrl; m_listCtrl = new MyListCtrl(m_panel, LIST_CTRL, wxDefaultPosition, wxDefaultSize, flags | wxBORDER_THEME | wxLC_EDIT_LABELS); + if ( old ) + { + wxSizer* const sizer = m_panel->GetSizer(); + sizer->Replace(old, m_listCtrl); + + delete old; + + sizer->Layout(); + } + switch ( flags & wxLC_MASK_TYPE ) { case wxLC_LIST: