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. SpriteKit屏幕截图的屏幕截图
- 4. C++ Windows屏幕截图
- 5. 屏幕截图的C++ CLI
- 6. 屏幕截图
- 7. 截取屏幕截图
- 8. Webdriver屏幕截图
- 9. UIWebView屏幕截图
- 10. iPhone屏幕截图
- 11. Roku屏幕截图
- 12. ASP.NET屏幕截图
- 13. iPhone:屏幕截图
- 14. android屏幕截图
- 15. UICollectionView屏幕截图
- 16. 屏幕截图未连接屏幕截图的软件(RDP)
- 17. 屏幕截图按住屏幕截图时卡住
- 18. 以当前屏幕的屏幕截图
- 19. 以整个屏幕的屏幕截图
- 20. 屏幕部分的屏幕截图
- 21. 屏幕截图到任何屏幕(Android Root,就像屏幕截图UX)
- 22. 通过C#发送屏幕截图
- 23. C#命令的屏幕截图
- 24. 用c安卓android屏幕截图#
- 25. Win32异常正在屏幕截图[c#]
- 26. 全屏幕截图与Cefsharp c#
- 27. C++控制台“屏幕截图”问题
- 28. Vista中的MFC应用程序无法使用屏幕截图
- 29. 使用c#截取屏幕截图使用c#
- 30. 锁定MFC屏幕
感谢您指点我在正确的方向 – mgalal 2012-08-07 23:49:31
虽然我结束了使用不同的方法来截图。我需要捕捉窗口的隐藏部分,PrintWindow也没有捕获它。 – mgalal 2012-08-08 00:01:23