+#ifdef __WIN32__
+
+bool wxBitmap::CopyFromIconOrCursor(const wxGDIImage& icon)
+{
+ // it may be either HICON or HCURSOR
+ HICON hicon = (HICON)icon.GetHandle();
+
+ ICONINFO iconInfo;
+ if ( !::GetIconInfo(hicon, &iconInfo) )
+ {
+ wxLogLastError("GetIconInfo");
+
+ return FALSE;
+ }
+
+ 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
+ refData->m_bitmapMask = new wxMask((WXHBITMAP)
+ wxInvertMask(iconInfo.hbmMask, w, h));
+
+#if WXWIN_COMPATIBILITY_2
+ refData->m_ok = TRUE;
+#endif // WXWIN_COMPATIBILITY_2
+
+ return TRUE;
+}
+
+#endif // Win32
+
+bool wxBitmap::CopyFromCursor(const wxCursor& cursor)