See http://search.9cbs.net/expert/topicview1.asp?id=2307620 By default, the contents of the screen are not included, but the mouse draws can be drawn to the captured image LPbitMapInfoHeader CaptureScreenframe (int LEFT) , int top, int width, int height, int tempDisableRect) {# ifndef _DIRECTX_captureScreenFrame HDC hScreenDC = :: GetDC (NULL); # else theApp.DirectXInit ();! # endif // if flashing rect if (flashingRect && tempDisableRect) {
IF (Autopan) {Pframe-> Setupregion (Left, Top, Width, Height, 1); DrawFlashingRect (True, 1);
} Else DrawFlashingRect (TRUE, 0);
} #Ifndef _DIRECTX_captureScreenFrame HDC hMemDC = :: CreateCompatibleDC (hScreenDC); HBITMAP hbm; hbm = CreateCompatibleBitmap (hScreenDC, width, height); HBITMAP oldbm = (HBITMAP) SelectObject (hMemDC, hbm); BitBlt (hMemDC, 0, 0, width , height, hScreenDC, left, top, SRCCOPY); #else theApp.DirectXCapture (left, top, width, height); HDC hMemDC = NULL; theApp.DirectXGetDC (hMemDC); # endif // Get Cursor Pos POINT xPoint; GetCursorPos (& XPoint); hcursor hcur = fetchcursorhandle (); xpoint.x- = left; xpoint.y- = top;
// Draw the highlightiff f (g_highlightcursor == 1) {
Point highlightpoint;
HighlightPoint.x = Xpoint.x -64; highlightpoint.y = xpoint.y -64; insertHighlight (hmemdc, highlightpoint.x, highlightpoint.y);
} // Draw the cursor if (g_recordcursor == 1) {iconInfo iconInfo; Bool ret; reset; if (hcur, & iconifo); if (re) {
XPoint.x - = iconinfo.xhotspot; Xpoint.y - = iconinfo.yhotspot;
// 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) } :: Drawicon (HMEMDC, XPoint.x, XPoint.y, HCur);
} // CString strText = COleDateTime :: GetCurrentTime () Format ();. // CRect rc (0,0,640,480); // DrawText (hMemDC, strText, -1, & rc, DT_LEFT); # ifndef _DIRECTX_captureScreenFrame SelectObject (hMemDC, oldbm); LPBITMAPINFOHEADER pBM_HEADER = (LPBITMAPINFOHEADER) GlobalLock (Bitmap2Dib (hbm, bits)); // LPBITMAPINFOHEADER pBM_HEADER = (LPBITMAPINFOHEADER) GlobalLock (Bitmap2Dib (hbm, 24)); #else theApp.DirectXReleaseDC (hMemDC); LPBITMAPINFOHEADER pBM_HEADER = ( LPBITMAPINFOHEADER) GlobalLock (theApp.DirectXGetCaptureBitmap (bits)); # endif if (pBM_HEADER == NULL) {// MessageBox (NULL, "Error reading a frame!", "Error", MB_OK | MB_ICONEXCLAMATION); AfxMessageBox (IDS_CAPTURE_FAIL); AfxPostQuitMessage (0); // exit (1);} #ifndef _DIRECTX_captureScreenFrame DeleteObject (hbm); DeleteDC (hMemDC); #endif // if flashing rect if (! flashingRect && tempDisableRect) {if (autopan) {DrawFlashingRect (FALSE, 1); Else DrawFlashingRect (false, 0);
} #Ifndef _directx_capturescreenframe ReleaseDC (NULL, HSCREENDC); #ELSE THEAPP.DIRECTXUNINIT (); # Endif Return PBM_HEADER;}