]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/dc.cpp
Added patch #412132 (Fix for bug #215410) (Mainly in CalcDimensions()),
[wxWidgets.git] / src / msw / dc.cpp
index 90433d392f8ed5887b35c637dbe6e8ae6239866b..1863a0d1da6daf2dd4d0a87a6112768c110c0b1d 100644 (file)
@@ -183,23 +183,34 @@ wxDC::wxDC()
 
     m_windowExtX = VIEWPORT_EXTENT;
     m_windowExtY = VIEWPORT_EXTENT;
-
-    m_hDCCount = 0;
 }
 
 
 wxDC::~wxDC()
 {
-    if ( m_hDC != 0 ) {
+    if ( m_hDC != 0 )
+    {
         SelectOldObjects(m_hDC);
-        if ( m_bOwnsDC ) {
-            if ( m_canvas == NULL )
-                ::DeleteDC(GetHdc());
+
+        // if we own the HDC, we delete it, otherwise we just release it
+
+        if ( m_bOwnsDC )
+        {
+            ::DeleteDC(GetHdc());
+        }
+        else // we don't own our HDC
+        {
+            if (m_canvas)
+            {
+                ::ReleaseDC(GetHwndOf(m_canvas), GetHdc());
+            }
             else
-                ::ReleaseDC((HWND)m_canvas->GetHWND(), GetHdc());
+            {
+                // Must have been a wxScreenDC
+                ::ReleaseDC((HWND) NULL, GetHdc());
+            }
         }
     }
-
 }
 
 // This will select current objects out of the DC,