CPaintDC dc(this); // device context for painting POINT xPoint; 
::GetCursorPos( &xPoint );  HCURSOR hCursor = ::GetCursor(); ICONINFO iconinfo;
int w = 0, h = 0; BOOL bRet = ::GetIconInfo( hCursor,  &iconinfo );
if (bRet) 
{
BITMAP bitmap = {0};
GetObject(iconinfo.hbmMask,sizeof(BITMAP),&bitmap);
w = bitmap.bmWidth;
h = bitmap.bmHeight; //need to delete the hbmMask and hbmColor bitmaps
//otherwise the program will crash after a while after running out of resource
if (iconinfo.hbmMask) 
::DeleteObject(iconinfo.hbmMask);
if (iconinfo.hbmColor) 
::DeleteObject(iconinfo.hbmColor);
} //HDC MemDCSrc = ::CreateCompatibleDC(dc);
HDC MemDC = ::CreateCompatibleDC(dc);
HBITMAP hBitmap = ::CreateCompatibleBitmap(MemDC,w,h);
::SelectObject(MemDC, hBitmap); ::DrawIconEx(MemDC, 0, 0, hCursor,w,h,0,NULL, DI_NORMAL);

::BitBlt(dc,50,50,w,h,MemDC,0,0,SRCCOPY);