+namespace
+{
+
+void ReverseBitmap(HBITMAP bitmap, int width, int height)
+{
+ MemoryHDC hdc;
+ SelectInHDC selBitmap(hdc, bitmap);
+ ::StretchBlt(hdc, width - 1, 0, -width, height,
+ hdc, 0, 0, width, height, SRCCOPY);
+}
+
+HCURSOR CreateReverseCursor(HCURSOR cursor)
+{
+ ICONINFO info;
+ if ( !::GetIconInfo(cursor, &info) )
+ return NULL;
+
+ HCURSOR cursorRev = NULL;
+
+ BITMAP bmp;
+ if ( ::GetObject(info.hbmMask, sizeof(bmp), &bmp) )
+ {
+ ReverseBitmap(info.hbmMask, bmp.bmWidth, bmp.bmHeight);
+ if ( info.hbmColor )
+ ReverseBitmap(info.hbmColor, bmp.bmWidth, bmp.bmHeight);
+ info.xHotspot = (DWORD)bmp.bmWidth - 1 - info.xHotspot;
+
+ cursorRev = ::CreateIconIndirect(&info);
+ }
+
+ ::DeleteObject(info.hbmMask);
+ if ( info.hbmColor )
+ ::DeleteObject(info.hbmColor);
+
+ return cursorRev;
+}
+
+} // anonymous namespace
+