]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/dc.cpp
added version info hidden dialog
[wxWidgets.git] / src / msw / dc.cpp
index 0efde7e988f38c273094060571607fa684464e44..0744dc251e735c28e8bee21c7602a8676f194f42 100644 (file)
@@ -23,7 +23,6 @@
 
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
-#include "wx/msw/private.h" // needs to be before #include <commdlg.h>
 
 #ifdef __BORLANDC__
     #pragma hdrstop
@@ -46,6 +45,8 @@
 #include <string.h>
 #include <math.h>
 
+#include "wx/msw/private.h" // needs to be before #include <commdlg.h>
+
 #if wxUSE_COMMON_DIALOGS
 #if wxUSE_NORLANDER_HEADERS
     #include <windows.h>
@@ -57,7 +58,7 @@
     #include <print.h>
 #endif
 
-    IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
+IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
 
 // ---------------------------------------------------------------------------
 // constants
@@ -1254,8 +1255,12 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest,
         const wxBitmap& bmp = source->m_selectedBitmap;
         mask = bmp.GetMask();
 
-        wxCHECK_MSG( bmp.Ok() && mask, FALSE,
-                     _T("can't blit with mask without mask") );
+        if ( !(bmp.Ok() && mask && mask->GetMaskBitmap()) )
+        {
+            // don't give assert here because this would break existing
+            // programs - just silently ignore useMask parameter
+            useMask = FALSE;
+        }
     }
 
     COLORREF old_textground = ::GetTextColor(GetHdc());
@@ -1288,16 +1293,24 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest,
     if (useMask)
     {
 #ifdef __WIN32__
-        if ( ::MaskBlt(GetHdc(), xdest, ydest,
-                       (int)width, (int)height,
-                       GetHdcOf(*source), xsrc, ysrc,
-                       (HBITMAP) mask->GetMaskBitmap(),
-                       0, 0, MAKEROP4(SRCCOPY, PATCOPY)) != 0 )
-        {
-            // Success
-            success = TRUE;
-        }
-        else
+        HBITMAP hbmpMask = wxInvertMask((HBITMAP)mask->GetMaskBitmap());
+
+        // we want the part of the image corresponding to the mask to be
+        // transparent, i.e. do PATCOPY there and apply dwRop elsewhere
+        const wxColour& colBg = m_backgroundBrush.GetColour();
+        HBRUSH hbrBg = (HBRUSH)::CreateSolidBrush(wxColourToRGB(colBg));
+        HBRUSH hbrOld = (HBRUSH)::SelectObject(GetHdc(), hbrBg);
+
+        success = ::MaskBlt(GetHdc(), xdest, ydest, width, height,
+                            GetHdcOf(*source), xsrc, ysrc,
+                            hbmpMask, 0, 0,
+                            MAKEROP4(PATCOPY, dwRop)) != 0;
+
+        (void)::SelectObject(GetHdc(), hbrOld);
+        ::DeleteObject(hbrOld);
+        ::DeleteObject(hbmpMask);
+
+        if ( !success )
 #endif // Win32
         {
             // Blit bitmap with mask