在得到屏幕DC之后,使用BitBlt函数,并不能把鼠标拷贝进去。
请问如何才能解决这个问题?

解决方案 »

  1.   

    这好象比较困难哦,是不是可以先获取鼠标位置,保存,再BitBlt,再把鼠标移到保存的位置?
      

  2.   

    因为通过 DC 方式捉图捉的是窗口的图像内容,鼠标指针并不含在窗口的图像内容里。
    所以除非自己捉图后画鼠标,或者通过 DirectX 等直接读取屏幕图像。
      

  3.   

    鼠标不属于GDI资源,屏幕铺捉是得不到的,你可以在内存中用CDC类来画鼠标~!
      

  4.   

    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 HighLight
    if (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;
    ret = GetIconInfo( hcur,  &iconinfo ); 
    if (ret) { 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;    
    }Command what is yours
    Conquer what is not
      

  5.   

    http://www.eaoo.com/design/list.asp?classid=2&Nclassid=13
      

  6.   

    jiangsheng(蒋晟.Net):
    哥们,你的代码太牛B了。谢了啊。
      

  7.   

    哥们,我通过GetCursor()得到的当前光标始终只是普通的箭头光标,当鼠标是其他形状的时候,得到也是这个普通的箭头,这个毛病该如何解决呢?