zoukankan      html  css  js  c++  java
  • 网摘-获取屏幕dc并且将其画面显示在窗体中

    获取屏幕dc并且将其画面显示在窗体中

      HWND hWnd = ::GetDesktopWindow();//获得屏幕的HWND.
     HDC hScreenDC = ::GetDC(hWnd);   //获得屏幕的HDC.
     HDC MemDC = ::CreateCompatibleDC(hScreenDC);
     RECT rect; 
     ::GetWindowRect(hWnd,&rect);
     SIZE screensize;
     screensize.cx=rect.right-rect.left;
     screensize.cy=rect.bottom-rect.top;
     hBitmap = ::CreateCompatibleBitmap(hScreenDC,screensize.cx,screensize.cy);
     HGDIOBJ hOldBMP = ::SelectObject(MemDC,hBitmap);
     ::BitBlt(MemDC,0,0,screensize.cx,screensize.cy,hScreenDC,rect.left,rect.top,SRCCOPY);//将屏幕画布拷贝到内存画布上
     ::SelectObject(MemDC,hOldBMP);
     ::DeleteObject(MemDC);
     ::ReleaseDC(hWnd,hScreenDC);
        CDC *pDC=GetDC();//获取窗体的cdc
     HDC dDlgDC=pDC->m_hDC;//获取窗体的hdc
     HDC MemDC1 = CreateCompatibleDC(dDlgDC);//创建画布
     HGDIOBJ hOldBMP1 = ::SelectObject(MemDC1,hBitmap);//选入画布
     ::StretchBlt(dDlgDC,0,0,600,400,MemDC1,0,0,screensize.cx,screensize.cy,SRCCOPY);//将内存画布缩略显示到窗体中
     ::SelectObject(MemDC1,hOldBMP1);//选出画布
     ::DeleteObject(MemDC1);//删除内存hdc
     ::ReleaseDC(m_hWnd,dDlgDC);//释放实际窗体的hdc

     

     

    windows AP:

    HDC GetDC( HWND hWnd // handle to window);

    Parameters

    hWnd

    [in] Handle to the window whose DC is to be retrieved. If this value is NULL, GetDC retrieves the DC for the entire screen.

    365个夜晚,我希望做到两天更一篇博客。加油,小白!
  • 相关阅读:
    如何获取地址栏中的参数
    Ajax基础知识
    什么是BFC
    111
    不定宽 块状元素居中3
    POJ 2104主席树
    可持久化数据结构之主席树
    线段树
    Splay 学习
    hello world
  • 原文地址:https://www.cnblogs.com/qq2806933146xiaobai/p/11137924.html
Copyright © 2011-2022 走看看