1 / 7
文档名称:

屏幕截图.doc

格式:doc   大小:22KB   页数:7页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

屏幕截图.doc

上传人:iris028 2020/3/9 文件大小:22 KB

下载得到文件列表

屏幕截图.doc

相关文档

文档介绍

文档介绍:屏幕截图[VC]屏幕截图像红蜻蜓,还有QQ等,上面的屏幕截图都非常的不错,那么,如何在自己的程序中加入这一功能呢,屏幕截图,实际上就是把屏幕拷贝下来,然后将其保存到文件或者保存到剪贴板,下面的函数,向你展示了这一功能:HBITMAPCopyScreenToBitmap(LPRECTlpRect){HDChSrcDC=NULL,hMemDC=NULL;HBITMAPhBitmap=NULL,hOldBitmap=NULL;intx1,y1,x2,y2;intnWidth,nHeight;intxScreen,yScreen;if(IsRectEmpty(lpRect))returnNULL;hSrcDC=CreateDC("DISPLAY",NULL,NULL,NULL);hMemDC=patibleDC(hSrcDC);x1=lpRect->left;y1=lpRect->top;x2=lpRect->right;y2=lpRect->bottom;xScreen=GetDeviceCaps(hSrcDC,HORZRES);yScreen=GetDeviceCaps(hSrcDC,VERTRES);if(x1<0)x1=0;if(y1<0)y1=0;if(x2>xScreen)x2=xScreen;if(y2>yScreen)y2=yScreen;nWidth=x2-x1;nHeight=y2-y1;hBitmap=patibleBitmap(hSrcDC,nWidth,nHeight);hOldBitmap=(HBITMAP)SelectObject(hMemDC,hBitmap);BitBlt(hMemDC,0,0,nWidth,nHeight,hSrcDC,x1,y1,OPY);hBitmap=(HBITMAP)SelectObject(hMemDC,hOldBitmap);DeleteDC(hSrcDC);DeleteDC(hMemDC);returnhBitmap;}BOOLSaveBitmapToFile(HBITMAPhBitmap,LPCTSTRlpFileName){HDChDC=NULL;intiBits=0;WORDwBitCount=0;DWORDdwPaletteSize=0;DWORDdwBmBitsSize=0,dwDibSize=0,dwWritten=0;BITMAPBitmap;BITMAPFILEHEADERbmfHdr;BITMAPINFOHEADERbi;LPBITMAPINFOHEADERlpbi;HANDLEfh=NULL,hDib=NULL,hPal=NULL,hOldPal=NULL;hDC=CreateDC("DISPLAY",NULL,NULL,NULL);if(hDC==NULL)returnFALSE;iBits=GetDeviceCaps(hDC,BITSPIXEL)*GetDeviceCaps(hDC,PLANES);DeleteDC(hDC);if(iBits<=1)wBitCount=1;elseif(iBits<=4)wBitCount=4;elseif(iBits<=8)wBitCount=8;elseif(iBits<=24)wBitCount=24;elseif(iBits<=