19,468
社区成员
发帖
与我相关
我的任务
分享
CDC *pDC=GetDesktopWindow()->GetDC();//屏幕DC
int BitPerPixel = pDC->GetDeviceCaps(BITSPIXEL);//获得颜色模式
int Width = pDC->GetDeviceCaps(HORZRES);
int Height = pDC->GetDeviceCaps(VERTRES);
CDC memDC;//内存DC
memDC.CreateCompatibleDC(pDC);
CBitmap memBitmap, *oldmemBitmap;//建立和屏幕兼容的bitmap
memBitmap.CreateCompatibleBitmap(pDC, Width, Height);
oldmemBitmap = memDC.SelectObject(&memBitmap);//将memBitmap选入内存DC
memDC.BitBlt(0, 0, Width, Height, pDC, 0, 0, SRCCOPY);//复制屏幕图像到内存DC
ShowWindow(SW_SHOWMAXIMIZED);
CClientDC cdc(this);
cdc.BitBlt(0,0,Width,Height,&memDC,0,0,SRCCOPY);
memDC.SelectObject(oldmemBitmap);
memDC.DeleteDC();
ReleaseDC(pDC);
int Width = GetSystemMetrics(SM_CXSCREEN);
int Height = GetSystemMetrics(SM_CYSCREEN);