diff --git a/include/wx/msw/window.h b/include/wx/msw/window.h index a6350c1afc..108b1468a5 100644 --- a/include/wx/msw/window.h +++ b/include/wx/msw/window.h @@ -428,7 +428,11 @@ public: // check if a native double-buffering applies for this window virtual bool IsDoubleBuffered() const; - + +#if wxABI_VERSION >= 20808 + void SetDoubleBuffered(bool on); +#endif + // synthesize a wxEVT_LEAVE_WINDOW event and set m_mouseInWindow to false void GenerateMouseLeave(); diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 19183730de..06f846259f 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -4176,17 +4176,32 @@ bool wxWindowMSW::HandlePower(WXWPARAM WXUNUSED_IN_WINCE(wParam), bool wxWindowMSW::IsDoubleBuffered() const { - for ( const wxWindowMSW *wnd = this; - wnd && !wnd->IsTopLevel(); wnd = - wnd->GetParent() ) - { - if ( ::GetWindowLong(GetHwndOf(wnd), GWL_EXSTYLE) & WS_EX_COMPOSITED ) + const wxWindowMSW *wnd = this; + do { + long style = ::GetWindowLong(GetHwndOf(wnd), GWL_EXSTYLE); + if ( (style & WS_EX_COMPOSITED) != 0 ) return true; - } - + wnd = wnd->GetParent(); + } while ( wnd && !wnd->IsTopLevel() ); + return false; } +void wxWindowMSW::SetDoubleBuffered(bool on) +{ + // Get the current extended style bits + long exstyle = ::GetWindowLong(GetHwnd(), GWL_EXSTYLE); + + // Twiddle the bit as needed + if ( on ) + exstyle |= WS_EX_COMPOSITED; + else + exstyle &= ~WS_EX_COMPOSITED; + + // put it back + ::SetWindowLong(GetHwnd(), GWL_EXSTYLE, exstyle); +} + // --------------------------------------------------------------------------- // owner drawn stuff // ---------------------------------------------------------------------------