能力值:
( LV2,RANK:10 )
|
-
-
2 楼
画图工具撒,我只晓得这个
|
能力值:
( LV3,RANK:20 )
|
-
-
3 楼
mfc我会,API不会
|
能力值:
( LV2,RANK:10 )
|
-
-
4 楼
BOOL CGetScreenTableDlg::CopyScreenToBitmap(CRect rect)
{
CDC dc;
dc.CreateDC("DISPLAY",NULL,NULL,NULL);
CBitmap bm;
bm.CreateCompatibleBitmap(&dc,rect.Width(),rect.Height());
CDC tdc;
tdc.CreateCompatibleDC(&dc);
CBitmap*pOld=tdc.SelectObject(&bm);
tdc.BitBlt(0,0,rect.Width(),rect.Height(),&dc,rect.left,rect.top,SRCCOPY);
tdc.SelectObject(pOld);
BITMAP btm;
bm.GetBitmap(&btm);
DWORD size=btm.bmWidthBytes*btm.bmHeight;
LPSTR lpData=(LPSTR)GlobalAllocPtr(GPTR,size);
BITMAPINFOHEADER bih;
bih.biBitCount=btm.bmBitsPixel;
bih.biClrImportant=0;
bih.biClrUsed=0;
bih.biCompression=0;
bih.biHeight=btm.bmHeight;
bih.biPlanes=1;
bih.biSize=sizeof(BITMAPINFOHEADER);
bih.biSizeImage=size;
bih.biWidth=btm.bmWidth;
bih.biXPelsPerMeter=0;
bih.biYPelsPerMeter=0;
GetDIBits(dc,bm,0,bih.biHeight,lpData,(BITMAPINFO*)&bih,DIB_RGB_COLORS);
BITMAPFILEHEADER bfh;
bfh.bfReserved1=bfh.bfReserved2=0;
bfh.bfType=((WORD)('M'<< 8)|'B');
bfh.bfSize=54+size;
bfh.bfOffBits=54;
CString strFilter = "BMP Files (*.bmp)|*.bmp|";
CString m_wszFileName= "CopyScreen.bmp";
CFileDialog dlgSave(FALSE, NULL, m_wszFileName, OFN_PATHMUSTEXIST | OFN_HIDEREADONLY, strFilter);
if (dlgSave.DoModal() == IDCANCEL)
return FALSE;
m_wszFileName = dlgSave.GetPathName();
CFile bf;
if(bf.Open(m_wszFileName,CFile::modeCreate|CFile::modeWrite))
{
bf.WriteHuge(&bfh,sizeof(BITMAPFILEHEADER));
bf.WriteHuge(&bih,sizeof(BITMAPINFOHEADER));
bf.WriteHuge(lpData,size);
bf.Close();
}
GlobalFreePtr(lpData);
return TRUE;
}
|