+ wxBitmapRefData *refData = new wxBitmapRefData;
+ m_refData = refData;
+
+ int w = icon.GetWidth(),
+ h = icon.GetHeight();
+
+ refData->m_width = w;
+ refData->m_height = h;
+ refData->m_depth = wxDisplayDepth();
+
+ refData->m_hBitmap = (WXHBITMAP)iconInfo.hbmColor;
+
+ // the mask returned by GetIconInfo() is inversed compared to the usual
+ // wxWin convention
+ HBITMAP hbmpMask = ::CreateBitmap(w, h, 1, 1, 0);
+
+ // the icons mask is opposite to the usual wxWin convention
+ HDC dcSrc = ::CreateCompatibleDC(NULL);
+ HDC dcDst = ::CreateCompatibleDC(NULL);
+ (void)SelectObject(dcSrc, iconInfo.hbmMask);
+ (void)SelectObject(dcDst, hbmpMask);
+
+ HBRUSH brush = ::CreateSolidBrush(RGB(255, 255, 255));
+ RECT rect = { 0, 0, w, h };
+ FillRect(dcDst, &rect, brush);
+
+ BitBlt(dcDst, 0, 0, w, h, dcSrc, 0, 0, SRCINVERT);
+
+ SelectObject(dcDst, NULL);
+ SelectObject(dcSrc, NULL);
+ DeleteDC(dcDst);
+ DeleteDC(dcSrc);
+
+ refData->m_bitmapMask = new wxMask((WXHBITMAP)hbmpMask);
+
+#if WXWIN_COMPATIBILITY_2
+ refData->m_ok = TRUE;
+#endif // WXWIN_COMPATIBILITY_2
+
+ return TRUE;
+}
+
+#endif // Win32
+
+bool wxBitmap::CopyFromCursor(const wxCursor& cursor)
+{
+ UnRef();
+
+ if ( !cursor.Ok() )
+ return FALSE;
+
+#ifdef __WIN16__
+ wxFAIL_MSG( _T("don't know how to convert cursor to bitmap") );
+
+ return FALSE;
+#else
+ return CopyFromIconOrCursor(cursor);
+#endif // Win16
+}
+
+bool wxBitmap::CopyFromIcon(const wxIcon& icon)
+{
+ UnRef();
+
+ if ( !icon.Ok() )
+ return FALSE;
+
+ // GetIconInfo() doesn't exist under Win16 and I don't know any other way
+ // to create a bitmap from icon there - but using this way we won't have
+ // the mask (FIXME)
+#ifdef __WIN16__
+ int width = icon.GetWidth(),
+ height = icon.GetHeight();
+
+ // copy the icon to the bitmap
+ ScreenHDC hdcScreen;
+ HDC hdc = ::CreateCompatibleDC(hdcScreen);
+ HBITMAP hbitmap = ::CreateCompatibleBitmap(hdcScreen, width, height);
+ HBITMAP hbmpOld = (HBITMAP)::SelectObject(hdc, hbitmap);
+
+ ::DrawIcon(hdc, 0, 0, GetHiconOf(icon));
+
+ ::SelectObject(hdc, hbmpOld);
+ ::DeleteDC(hdc);
+
+ wxBitmapRefData *refData = new wxBitmapRefData;
+ m_refData = refData;
+
+ refData->m_width = width;
+ refData->m_height = height;
+ refData->m_depth = wxDisplayDepth();
+
+ refData->m_hBitmap = (WXHBITMAP)hbitmap;
+
+#if WXWIN_COMPATIBILITY_2
+ refData->m_ok = TRUE;
+#endif // WXWIN_COMPATIBILITY_2
+
+ return TRUE;
+#else // Win32
+ return CopyFromIconOrCursor(icon);
+#endif // Win16/Win32