+ HBITMAP hbmpMask = 0;
+
+ if ( useMask )
+ {
+ wxMask *mask = bmp.GetMask();
+ if ( mask )
+ hbmpMask = (HBITMAP)mask->GetMaskBitmap();
+
+ if ( !hbmpMask )
+ {
+ // don't give assert here because this would break existing
+ // programs - just silently ignore useMask parameter
+ useMask = FALSE;
+ }
+ }
+
+ if ( useMask )
+ {
+#ifdef __WIN32__
+ HDC hdcMem = ::CreateCompatibleDC(GetHdc());
+ ::SelectObject(hdcMem, GetHbitmapOf(bmp));
+
+ // this will only work if the transparent part of our bitmap is black
+ // because it is combined with the destination rectangle using OR, so
+ // it won't be really transparent otherwise - I don't know what to do
+ // about it, may be use MAKEROP4(SRCCOPY, DSTINVERT) twice? Or create a
+ // copy of the bitmap with the transparent part replaced with black
+ // pixels?
+ bool ok = ::MaskBlt(GetHdc(), x, y, width, height,
+ hdcMem, 0, 0,
+ hbmpMask, 0, 0,
+ MAKEROP4(SRCCOPY, SRCPAINT)) != 0;
+ ::DeleteDC(hdcMem);
+
+ if ( !ok )
+#endif // Win32
+ {
+ // VZ: this is incorrect, Blit() doesn't (and can't) draw
+ // transparently, but it's still better than nothing at all
+
+ // Rather than reproduce wxDC::Blit, let's do it at the wxWin API level
+ wxMemoryDC memDC;
+ memDC.SelectObject(bmp);
+
+ Blit(x, y, width, height, &memDC, 0, 0, wxCOPY, useMask);
+
+ memDC.SelectObject(wxNullBitmap);
+ }
+ }
+ else // no mask, just use BitBlt()