+ if ( GetPageCount() == 0 )
+ {
+ // Prevents droppings on resize, but does cause some flicker
+ // when there are no pages.
+ Refresh();
+ event.Skip();
+ return;
+ }
+#ifndef __WXWINCE__
+ else
+ {
+ // Without this, we can sometimes get droppings at the edges
+ // of a notebook, for example a notebook in a splitter window.
+ // This needs to be reconciled with the RefreshRect calls
+ // at the end of this function, which weren't enough to prevent
+ // the droppings.
+
+ wxSize sz = GetClientSize();
+
+ // Refresh right side
+ wxRect rect(sz.x-4, 0, 4, sz.y);
+ RefreshRect(rect);
+
+ // Refresh bottom side
+ rect = wxRect(0, sz.y-4, sz.x, 4);
+ RefreshRect(rect);
+
+ // Refresh left side
+ rect = wxRect(0, 0, 4, sz.y);
+ RefreshRect(rect);
+ }
+#endif // !__WXWINCE__
+
+ // fit all the notebook pages to the tab control's display area
+
+ RECT rc;
+ rc.left = rc.top = 0;
+ GetSize((int *)&rc.right, (int *)&rc.bottom);
+
+ // save the total size, we'll use it below
+ int widthNbook = rc.right - rc.left,
+ heightNbook = rc.bottom - rc.top;
+
+ // there seems to be a bug in the implementation of TabCtrl_AdjustRect(): it
+ // returns completely false values for multiline tab controls after the tabs
+ // are added but before getting the first WM_SIZE (off by ~50 pixels, see
+ //
+ // http://sf.net/tracker/index.php?func=detail&aid=645323&group_id=9863&atid=109863
+ //
+ // and the only work around I could find was this ugly hack... without it
+ // simply toggling the "multiline" checkbox in the notebook sample resulted
+ // in a noticeable page displacement
+ if ( HasFlag(wxNB_MULTILINE) )
+ {
+ // avoid an infinite recursion: we get another notification too!
+ static bool s_isInOnSize = false;
+
+ if ( !s_isInOnSize )
+ {
+ s_isInOnSize = true;
+ SendMessage(GetHwnd(), WM_SIZE, SIZE_RESTORED,
+ MAKELPARAM(rc.right, rc.bottom));
+ s_isInOnSize = false;
+ }
+ }
+
+#if wxUSE_UXTHEME
+ // background bitmap size has changed, update the brush using it too
+ UpdateBgBrush();
+#endif // wxUSE_UXTHEME
+
+ TabCtrl_AdjustRect(GetHwnd(), false, &rc);
+
+ int width = rc.right - rc.left,
+ height = rc.bottom - rc.top;
+ size_t nCount = m_pages.Count();
+ for ( size_t nPage = 0; nPage < nCount; nPage++ ) {
+ wxNotebookPage *pPage = m_pages[nPage];
+ pPage->SetSize(rc.left, rc.top, width, height);
+ }
+
+
+ // unless we had already repainted everything, we now need to refresh
+ if ( !HasFlag(wxFULL_REPAINT_ON_RESIZE) )
+ {
+ // invalidate areas not covered by pages
+ RefreshRect(wxRect(0, 0, widthNbook, rc.top), false);
+ RefreshRect(wxRect(0, rc.top, rc.left, height), false);
+ RefreshRect(wxRect(0, rc.bottom, widthNbook, heightNbook - rc.bottom),
+ false);
+ RefreshRect(wxRect(rc.right, rc.top, widthNbook - rc.right, height),
+ false);
+ }
+
+#if USE_NOTEBOOK_ANTIFLICKER
+ // subclass the spin control used by the notebook to scroll pages to
+ // prevent it from flickering on resize
+ if ( !m_hasSubclassedUpdown )
+ {
+ // iterate over all child windows to find spin button
+ for ( HWND child = ::GetWindow(GetHwnd(), GW_CHILD);
+ child;
+ child = ::GetWindow(child, GW_HWNDNEXT) )
+ {
+ wxWindow *childWindow = wxFindWinFromHandle((WXHWND)child);
+
+ // see if it exists, if no wxWindow found then assume it's the spin
+ // btn
+ if ( !childWindow )
+ {
+ // subclass the spin button to override WM_ERASEBKGND
+ if ( !gs_wndprocNotebookSpinBtn )
+ gs_wndprocNotebookSpinBtn = (WXFARPROC)wxGetWindowProc(child);
+
+ wxSetWindowProc(child, wxNotebookSpinBtnWndProc);
+ m_hasSubclassedUpdown = true;
+ break;
+ }
+ }
+ }
+#endif // USE_NOTEBOOK_ANTIFLICKER
+
+ event.Skip();
+}