X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/837e57436a89516a5fa9f478f401e06bd872c17c..619d05280a2b929908565d87a6edbba5a04dc21b:/src/msw/notebook.cpp diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index d6c5fc5234..d94b86b315 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -274,11 +274,22 @@ bool wxNotebook::DeletePage(int nPage) { wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, _T("notebook page out of range") ); + if ( m_nSelection == nPage ) { + // advance selection backwards - the page being deleted shouldn't be left + // selected + AdvanceSelection(FALSE); + } + TabCtrl_DeleteItem(m_hwnd, nPage); delete m_aPages[nPage]; m_aPages.Remove(nPage); + if ( m_aPages.IsEmpty() ) { + // no selection if the notebook became empty + m_nSelection = -1; + } + return TRUE; } @@ -370,6 +381,11 @@ bool wxNotebook::InsertPage(int nPage, // this updates internal flag too - otherwise it will get out of sync pPage->Show(FALSE); + // FIXME this is ugly, I'm breaking my own rules... but needed to get display + // right (why?) + wxSizeEvent event; + OnSize(event); + return TRUE; }