0
A
回答
0
最後,我終於實現了這種方式,因爲我想捕捉即使窗口的隱蔽部位(由於內容超出屏幕和要求滾動):
CDC* WindowToCaptureDC = AfxGetMainWnd()->GetWindowDC();
CDC CaptureDC;
CDC MemDC;
MemDC.CreateCompatibleDC(WindowToCaptureDC);
CaptureDC.CreateCompatibleDC(WindowToCaptureDC);
CBitmap CaptureBmp;
CBitmap ResizeBmp;
int pWidth = grid.tableWidth + grid.marginLeft*2;
int pHeight = grid.tableHeight + grid.marginBottom;
CaptureBmp.CreateCompatibleBitmap(WindowToCaptureDC, pWidth, pHeight);
CaptureDC.SelectObject(&CaptureBmp);
CBrush brush(RGB(255, 255, 255));
CaptureDC.SelectObject(&brush);
CaptureDC.Rectangle(0, 0, pWidth, pHeight);
///德魯物品進入CaptureDC像我一樣的OnDraw中的位置///
double width = //desired width;
double height = //desired width;
//maintain aspect ratio
if(pWidth!=width || pHeight!=height)
{
double w = width/pWidth;
double h = height/pHeight;
if(w < h)
height = height*w;
else
width = width*h;
}
ResizeBmp.CreateCompatibleBitmap(WindowToCaptureDC, width, height);
MemDC.SelectObject(&ResizeBmp);
MemDC.StretchBlt(0, 0, width, height, &CaptureDC, 0, 0, pWidth, pHeight, SRCCOPY);
CImage TempImageObj;
TempImageObj.Attach((HBITMAP)ResizeBmp.Detach());
CString filePath = _T("LOCATION\\image.bmp");
TempImageObj.Save(filePath);
0
回答is here
void CScreenShotDlg::OnPaint()
{
// device context for painting
CPaintDC dc(this);
// Get the window handle of calculator application.
HWND hWnd = ::FindWindow(0, _T("Calculator"));
// Take screenshot.
PrintWindow(hWnd,
dc.GetSafeHdc(),
0);
}
相關問題
- 1. C++屏幕截圖
- 2. C++截取屏幕截圖
- 3. 屏幕截圖的C++ CLI
- 4. 屏幕截圖
- 5. 截取屏幕截圖
- 6. iPhone:屏幕截圖
- 7. Webdriver屏幕截圖
- 8. ASP.NET屏幕截圖
- 9. iPhone屏幕截圖
- 10. Roku屏幕截圖
- 11. 屏幕截圖按住屏幕截圖時卡住
- 12. 以當前屏幕的屏幕截圖
- 13. 以整個屏幕的屏幕截圖
- 14. 通過C#發送屏幕截圖
- 15. Vista中的MFC應用程序無法使用屏幕截圖
- 16. 使用c#截取屏幕截圖使用c#
- 17. osx上的屏幕截圖
- 18. iOS屏幕截圖延遲
- 19. Android設備屏幕截圖
- 20. 跨平臺屏幕截圖
- 21. 窗口的屏幕截圖
- 22. 瀏覽器屏幕截圖
- 23. 屏幕截圖ala Draw Something
- 24. iOS:獲取屏幕截圖
- 25. 捕獲屏幕截圖
- 26. InAppBrowser的屏幕截圖?
- 27. python中的屏幕截圖
- 28. Android - 拍攝屏幕截圖
- 29. ffmpeg獲取屏幕截圖
- 30. Haskell中的屏幕截圖?
感謝您指點我在正確的方向 – mgalal 2012-08-07 23:49:31
雖然我結束了使用不同的方法來截圖。我需要捕捉窗口的隱藏部分,PrintWindow也沒有捕獲它。 – mgalal 2012-08-08 00:01:23