我想截取某窗体 如"计算器"的 按键区的截图! 怎么办?  请用BitBlt实现!
我用C#完成了,但是C++不知道怎么用!

解决方案 »

  1.   

    先FindWindow找到"计算器",截图的时候获取rect的时候,就抛弃上一部分不是按键区的
    http://blog.csdn.net/laolei1986/article/details/5955257
      

  2.   

    参考void CZoomPartView::OnMouseMove(UINT nFlags, CPoint point)  
    {
    //计算要放大的局部矩形的源图像位置和目标位置
    CString cord;
    int dd;
      CRect srect,drect,mrect;
    srect.left = point.x - s;
    srect.top = point.y - s;
    srect.right = point.x + s;
    srect.bottom = point.y + s;drect.left = point.x - d;
    drect.top = point.y - d;
    drect.right = point.x + d;
    drect.bottom = point.y + d;mrect.left = oldx - d;
    mrect.top = oldy - d;
    mrect.right = oldx + d;
    mrect.bottom = oldy + d;
    dd = 2*d;
    CDC * pDC = GetDC();
    OnPrepareDC(pDC);
    //放大图像
    if (recover)
    {
    pDC->BitBlt(mrect.left,mrect.top,dd,dd,
    m_pdcMem,mrect.left,mrect.top,mana);
    }
    pDC->StretchBlt(drect.left,drect.top,
    drect.Width(),drect.Height(),m_pdcMem,srect.left,
    srect.top,srect.Width(),srect.Height(),SRCCOPY);
    oldx = point.x; oldy = point.y;
    ReleaseDC(pDC);recover = true;CView::OnMouseMove(nFlags, point);
    }void CZoomPartView::OnLButtonDown(UINT nFlags, CPoint point)  
    {
    //如果鼠标位置不在位图上,则还原位图大小显示
    CRect rc(0,0,m_sizeSource.cx,m_sizeSource.cy);
    if(!rc.PtInRect(point))
    {
    Invalidate();
    }
    else if (d > 5)//如果放大倍数大于5,就继续减小放大倍数,然后进行放大显示
    {
    CDC * pDC = GetDC();
    pDC->StretchBlt(oldx - d,oldy - d,2*d,
    2*d,m_pdcMem,oldx - d,oldy - d,2*d,2*d,mana);
    d -= 10;
    ReleaseDC(pDC);
    CZoomPartView::OnMouseMove(nFlags, point);
    }  
    CView::OnLButtonDown(nFlags, point);
    }void CZoomPartView::OnRButtonDown(UINT nFlags, CPoint point)  
    {
    //如果鼠标位置不在位图上,则还原位图大小显示
    CRect rc(0,0,m_sizeSource.cx,m_sizeSource.cy);
    if(!rc.PtInRect(point))
    {
    Invalidate();
    }
    else if (d <300)//如果放大倍数小于150,就继续增加放大倍数,然后进行放大显示
    {  
    d += 10;
    CZoomPartView::OnMouseMove(nFlags, point);  
    }  
    CView::OnRButtonDown(nFlags, point);
    }
      

  3.   

    看看这个Blog,是输入屏幕的RECT位置的窗体RECT截图