From 43a997b6e2064a189fa73ca1816908fb740ce297 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 16 Aug 2002 22:57:04 +0000 Subject: [PATCH] a better fix for notebook page not being refreshed after Delete() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16561 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/notebook.cpp | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index 065f983c79..d8a82f4809 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -320,16 +320,36 @@ wxNotebookPage *wxNotebook::DoRemovePage(int nPage) } else // notebook still not empty { - // refresh the selected page and change it if it became invalid + // change the selected page if it was deleted or became invalid + int selNew; if ( m_nSelection == GetPageCount() ) { - m_nSelection--; + // last page deleted, make the new last page the new selection + selNew = m_nSelection - 1; } + else if ( nPage <= m_nSelection ) + { + // we must show another page, even if it has the same index + selNew = m_nSelection; + } + else // nothing changes for the currently selected page + { + selNew = -1; - // force ChangePage() to really do something - int sel = m_nSelection; - m_nSelection = -1; - SetSelection(sel); + // we still must refresh the current page: this needs to be done + // for some unknown reason if the tab control shows the up-down + // control (i.e. when there are too many pages) -- otherwise after + // deleting a page nothing at all is shown + m_pages[m_nSelection]->Refresh(); + } + + if ( selNew != -1 ) + { + // m_nSelection must be always valid so reset it before calling + // SetSelection() + m_nSelection = -1; + SetSelection(selNew); + } } return pageRemoved; -- 2.47.2