// 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
#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>
#include <print.h>
#endif
- IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
+IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
// ---------------------------------------------------------------------------
// constants
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());
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