X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e32703a9d76b180e09571a7a0a5e8a2866c329ae..b9efe021b554fa3967d1442cf758435c5cd5ae8f:/src/msw/notebook.cpp diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index f5aa19e983..5694d072b9 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -229,6 +229,10 @@ void wxNotebook::Init() #if wxUSE_UXTHEME m_hbrBackground = NULL; #endif // wxUSE_UXTHEME + +#if USE_NOTEBOOK_ANTIFLICKER + m_hasSubclassedUpdown = false; +#endif // USE_NOTEBOOK_ANTIFLICKER } // default for dynamic class @@ -493,12 +497,12 @@ wxRect wxNotebook::GetPageSize() const ::GetClientRect(GetHwnd(), &rc); // 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 ( !HasFlag(wxNB_MULTILINE) || (rc.right > 20 && rc.bottom > 20) ) + // cause a crash on win2k or on XP with themes disabled if either + // wxNB_MULTILINE is used or tabs are placed on a side, if the rectangle + // is too small. + // + // The value of 20 is chosen arbitrarily but seems to work + if ( rc.right > 20 && rc.bottom > 20 ) { TabCtrl_AdjustRect(GetHwnd(), false, &rc); @@ -921,7 +925,7 @@ void wxNotebook::OnSize(wxSizeEvent& event) #if USE_NOTEBOOK_ANTIFLICKER // subclass the spin control used by the notebook to scroll pages to // prevent it from flickering on resize - if ( !gs_wndprocNotebookSpinBtn ) + if ( !m_hasSubclassedUpdown ) { // iterate over all child windows to find spin button for ( HWND child = ::GetWindow(GetHwnd(), GW_CHILD); @@ -935,9 +939,11 @@ void wxNotebook::OnSize(wxSizeEvent& event) if ( !childWindow ) { // subclass the spin button to override WM_ERASEBKGND - gs_wndprocNotebookSpinBtn = (WXFARPROC)wxGetWindowProc(child); + if ( !gs_wndprocNotebookSpinBtn ) + gs_wndprocNotebookSpinBtn = (WXFARPROC)wxGetWindowProc(child); wxSetWindowProc(child, wxNotebookSpinBtnWndProc); + m_hasSubclassedUpdown = true; break; } } @@ -961,18 +967,14 @@ void wxNotebook::OnSelChange(wxNotebookEvent& event) { wxNotebookPage *pPage = m_pages[sel]; pPage->Show(true); - pPage->SetFocus(); - - // If the newly focused window is not a child of the new page, - // SetFocus was not successful and the notebook itself should be - // focused - wxWindow *currentFocus = FindFocus(); - wxWindow *startFocus = currentFocus; - while ( currentFocus && currentFocus != pPage && currentFocus != this ) - currentFocus = currentFocus->GetParent(); - - if ( startFocus == pPage || currentFocus != pPage ) - SetFocus(); + + // As per bug report: + // http://sourceforge.net/tracker/index.php?func=detail&aid=1150659&group_id=9863&atid=109863, + // we should not set the page focus (and thereby the focus for + // a child window) since it erroneously selects radio button controls and also + // breaks keyboard handling for a notebook's scroll buttons. So + // we always focus the notebook and not the page. + SetFocus(); } else // no pages in the notebook, give the focus to itself