HBITMAP CBitmapDlg::GetScreen()
{
 HWND hwnd=::GetDesktopWindow();
 HDC hsrc=::GetDC(hwnd);
 HDC hmemdc=::CreateCompatibleDC(hsrc);
 RECT rc;
 ::GetWindowRect(hwnd,&rc);
 SIZE sz;
 sz.cx=rc.right-rc.left;
 sz.cy=rc.bottom-rc.top;
 HBITMAP hbmp=::CreateCompatibleBitmap(hsrc,sz.cx,sz.cy);
 HGDIOBJ holdbmp=::SelectObject(hmemdc,hbmp);
 ::BitBlt(hmemdc,0,0,sz.cx,sz.cy,hsrc,rc.left,rc.top,SRCCOPY);
 ::SelectObject(hmemdc,holdbmp);
 ::DeleteObject(hmemdc);
    ::ReleaseDC(hwnd,hsrc);
 return hbmp;
}
posted on 2009-09-29 10:54  yangjie  阅读(413)  评论(0编辑  收藏  举报