X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a58a12e9b7196c339c1c1d282ede158a70644e07..28be2e8a170979d476a5ea4f585505b8a2f5af27:/src/msw/bitmap.cpp diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index f0e07174d5..b5bd43e892 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -86,7 +86,7 @@ void wxBitmapRefData::Free() { if ( !::DeleteObject((HBITMAP)m_hBitmap) ) { - wxLogLastError("DeleteObject(hbitmap)"); + wxLogLastError(wxT("DeleteObject(hbitmap)")); } } @@ -117,7 +117,7 @@ bool wxBitmap::CopyFromIconOrCursor(const wxGDIImage& icon) ICONINFO iconInfo; if ( !::GetIconInfo(hicon, &iconInfo) ) { - wxLogLastError("GetIconInfo"); + wxLogLastError(wxT("GetIconInfo")); return FALSE; } @@ -269,7 +269,7 @@ wxBitmap::wxBitmap(const char bits[], int width, int height, int depth) HBITMAP hbmp = ::CreateBitmap(width, height, 1, depth, data); if ( !hbmp ) { - wxLogLastError("CreateBitmap"); + wxLogLastError(wxT("CreateBitmap")); } if ( data != bits ) @@ -326,7 +326,7 @@ bool wxBitmap::Create(int w, int h, int d) hbmp = ::CreateBitmap(w, h, 1, d, NULL); if ( !hbmp ) { - wxLogLastError("CreateBitmap"); + wxLogLastError(wxT("CreateBitmap")); } } else @@ -335,7 +335,7 @@ bool wxBitmap::Create(int w, int h, int d) hbmp = ::CreateCompatibleBitmap(dc, w, h); if ( !hbmp ) { - wxLogLastError("CreateCompatibleBitmap"); + wxLogLastError(wxT("CreateCompatibleBitmap")); } GetBitmapData()->m_depth = wxDisplayDepth(); @@ -382,8 +382,7 @@ bool wxBitmap::Create(void *data, long type, int width, int height, int depth) if ( !handler ) { - wxLogDebug(wxT("Failed to create bitmap: no bitmap handler for " - "type %d defined."), type); + wxLogDebug(wxT("Failed to create bitmap: no bitmap handler for type %d defined."), type); return FALSE; } @@ -653,36 +652,42 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour) HDC destDC = ::CreateCompatibleDC(NULL); if ( !srcDC || !destDC ) { - wxLogLastError("CreateCompatibleDC"); + wxLogLastError(wxT("CreateCompatibleDC")); } - if ( !::SelectObject(srcDC, GetHbitmapOf(bitmap)) ) + bool ok = TRUE; + + HGDIOBJ hbmpSrcOld = ::SelectObject(srcDC, GetHbitmapOf(bitmap)); + if ( !hbmpSrcOld ) { - wxLogLastError("SelectObject"); + wxLogLastError(wxT("SelectObject")); + + ok = FALSE; } - if ( !::SelectObject(destDC, (HBITMAP)m_maskBitmap) ) + + HGDIOBJ hbmpDstOld = ::SelectObject(destDC, (HBITMAP)m_maskBitmap); + if ( !hbmpDstOld ) { - wxLogLastError("SelectObject"); + wxLogLastError(wxT("SelectObject")); + + ok = FALSE; } // this is not very efficient, but I can't think of a better way of doing // it - for ( int w = 0; w < width; w++ ) + for ( int w = 0; ok && (w < width); w++ ) { - for ( int h = 0; h < height; h++ ) + for ( int h = 0; ok && (h < height); h++ ) { COLORREF col = GetPixel(srcDC, w, h); if ( col == CLR_INVALID ) { - wxLogLastError("GetPixel"); + wxLogLastError(wxT("GetPixel")); // doesn't make sense to continue - ::SelectObject(srcDC, 0); - ::DeleteDC(srcDC); - ::SelectObject(destDC, 0); - ::DeleteDC(destDC); + ok = FALSE; - return FALSE; + break; } if ( col == maskColour ) @@ -696,12 +701,12 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour) } } - ::SelectObject(srcDC, 0); + ::SelectObject(srcDC, hbmpSrcOld); ::DeleteDC(srcDC); - ::SelectObject(destDC, 0); + ::SelectObject(destDC, hbmpDstOld); ::DeleteDC(destDC); - return TRUE; + return ok; } // ---------------------------------------------------------------------------- @@ -837,13 +842,13 @@ extern HBITMAP wxInvertMask(HBITMAP hbmpMask, int w, int h) HDC hdcDst = ::CreateCompatibleDC(NULL); if ( !hdcSrc || !hdcDst ) { - wxLogLastError("CreateCompatibleDC"); + wxLogLastError(wxT("CreateCompatibleDC")); } HBITMAP hbmpInvMask = ::CreateBitmap(w, h, 1, 1, 0); if ( !hbmpInvMask ) { - wxLogLastError("CreateBitmap"); + wxLogLastError(wxT("CreateBitmap")); } ::SelectObject(hdcSrc, hbmpMask); @@ -852,7 +857,7 @@ extern HBITMAP wxInvertMask(HBITMAP hbmpMask, int w, int h) hdcSrc, 0, 0, NOTSRCCOPY) ) { - wxLogLastError("BitBlt"); + wxLogLastError(wxT("BitBlt")); } ::DeleteDC(hdcSrc);