]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/notebook.cpp
Applied gsockmsw.c 1.20 to 1.25 changes
[wxWidgets.git] / src / msw / notebook.cpp
index dffa7e5d60b68b03427c6c4b8a01380e69d1cdb8..7e3bbcbd498ab9f82c0ad9c6ca198d48b1139d64 100644 (file)
@@ -471,9 +471,18 @@ void wxNotebook::AdjustPageSize(wxNotebookPage *page)
 
     // get the page size from the notebook size
     GetSize((int *)&rc.right, (int *)&rc.bottom);
-    TabCtrl_AdjustRect(m_hwnd, false, &rc);
 
-    page->SetSize(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top);
+    // This check is to work around a bug in TabCtrl_AdjustRect which will
+    // cause a crash on win2k, or on XP with themes disabled, if the
+    // wxNB_MULTILINE style is used and the rectangle is very small, (such as
+    // when the notebook is first created.)  The value of 20 is just
+    // arbitrarily chosen, if there is a better way to determine this value
+    // then please do so.  --RD
+    if (rc.right > 20 && rc.bottom > 20)
+    {
+        TabCtrl_AdjustRect(m_hwnd, false, &rc);
+        page->SetSize(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top);
+    }
 }
 
 // ----------------------------------------------------------------------------
@@ -544,6 +553,7 @@ bool wxNotebook::DeleteAllPages()
 
   m_nSelection = -1;
 
+  InvalidateBestSize();
   return true;
 }
 
@@ -660,6 +670,7 @@ bool wxNotebook::InsertPage(size_t nPage,
     if ( selNew != -1 )
         SetSelection(selNew);
 
+    InvalidateBestSize();
     return true;
 }