My English is poor,sorry.
I copy screen into a file,and then I open the file,
I couldn't see the mouse,why?How to solve it?
Look:
Code:
SetCursorPos(300,300);
Sleep(3000);
HDC hdc;
hdc=CreateDC(TEXT("DISPLAY"),NULL,NULL,NULL);
int cx,cy;
cx=GetSystemMetrics(SM_CXSCREEN);
cy=GetSystemMetrics(SM_CYSCREEN);
HDC memhdc;
memhdc=CreateCompatibleDC(hdc);
HBITMAP hBitmap,holdBitmap;
hBitmap=CreateCompatibleBitmap(hdc,cx,cy);
holdBitmap=(HBITMAP)SelectObject(memhdc,hBitmap);
BitBlt(memhdc,0,0,cx,cy,hdc,0,0,SRCCOPY);
BITMAP bitmap;
GetObject(hBitmap,sizeof(BITMAP),&bitmap);
DWORD size=bitmap.bmWidthBytes*bitmap.bmHeight;
HGLOBAL hMem =GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT,size);
LPSTR lpData = (LPSTR)GlobalLock(hMem);
BITMAPINFOHEADER bih;
bih.biSize=sizeof(BITMAPINFOHEADER);
bih.biWidth=bitmap.bmWidth;
bih.biHeight=bitmap.bmHeight;
bih.biPlanes=1;
bih.biBitCount=bitmap.bmBitsPixel;
bih.biCompression=0;
bih.biSizeImage=size;
bih.biXPelsPerMeter=0;
bih.biYPelsPerMeter=0;
bih.biClrUsed=0;
bih.biClrImportant=0;
GetDIBits(memhdc,hBitmap,0,bih.biHeight,lpData,(BITMAPINFO*)&bih,DIB_RGB_COLORS);
BITMAPFILEHEADER bfh;
bfh.bfType=((WORD)('M'<< 8)|'B');
bfh.bfSize=54+size;
bfh.bfReserved1=bfh.bfReserved2=0;
bfh.bfOffBits=54;
CFile bf;
if(bf.Open("D:\\wt.bmp",CFile::modeCreate|CFile::modeWrite))
{
bf.WriteHuge(&bfh,sizeof(BITMAPFILEHEADER));
bf.WriteHuge(&bih,sizeof(BITMAPINFOHEADER));
bf.WriteHuge(lpData,size);
bf.Close();
}
GlobalUnlock(hMem);
GlobalFree(hMem);
hBitmap=(HBITMAP)SelectObject(memhdc,holdBitmap);
DeleteObject(hBitmap);
DeleteDC(memhdc);
DeleteDC(hdc);