]> git.saurik.com Git - wxWidgets.git/commitdiff
Add a SetDoubleBuffered method for wxMSW (XP+)
authorRobin Dunn <robin@alldunn.com>
Mon, 2 Jun 2008 18:30:13 +0000 (18:30 +0000)
committerRobin Dunn <robin@alldunn.com>
Mon, 2 Jun 2008 18:30:13 +0000 (18:30 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53930 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/window.h
src/msw/window.cpp

index 81f2072fada2d03fc9509ac019d9403d8bdb0138..3f068dddd6911fc6da30df84fcd9a338031b75de 100644 (file)
@@ -442,7 +442,9 @@ public:
 
     // check if a native double-buffering applies for this window
     virtual bool IsDoubleBuffered() const;
-
+    
+    void SetDoubleBuffered(bool on);
+    
     // synthesize a wxEVT_LEAVE_WINDOW event and set m_mouseInWindow to false
     void GenerateMouseLeave();
 
index 3702df9b6cc9fa51db08ac1fa0391f90caa0c76c..1101fb474c0ad915f414d147009a6ad5598a9a00 100644 (file)
@@ -4257,17 +4257,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
 // ---------------------------------------------------------------------------