屏幕抓图

来源:互联网 发布:单片机电子琴课程设计 编辑:程序博客网 时间:2024/04/30 06:26
 CWnd*  wnd = GetDesktopWindow();  
        CWindowDC cdc(wnd);  
        int width = GetSystemMetrics(SM_CXSCREEN);  
        int heigth = GetSystemMetrics(SM_CYSCREEN);  
        CRect rect;  
        GetClientRect(&rect);  
        CDC memdc;  
        memdc.CreateCompatibleDC(&cdc);  
        btmp.CreateCompatibleBitmap(&cdc, width, heigth);  
      
        memdc.SelectObject(&btmp);  
        CClientDC dc(this);  
        memdc.BitBlt(0,0, rect.Width(), rect.Height(), &cdc, 0, 0, SRCCOPY);  
        dc.BitBlt(0,0, rect.Width(), rect.Height(), &memdc, 0, 0, SRCCOPY);//这个之前调用  
        memdc.DeleteDC();  
        btmp.Detach();    
         
0 0