简体   繁体   中英

How take screenshot of scrolling window in C#

What is the easiest way in C# to take a screenshot of a complete scrolling Window?

I have sceen examples on here using a web browser, but in this case the window is a Windows desktop application.

You can get windows to redirect a WM_PAINT to an offscreen buffer with WM_PRINT and WM_PRINTCLIENT. This is better than screenscraping because it makes sure that obscured parts of a window(behind other windows) is painted anyway. If your target window scrolls by scrolling a child window position, WM_PRINT should apply. Just maybe it also helps your scenario.

Just 3 lines of code is enough

Bitmap b = new Bitmap(pnlOuter.Width, pnlOuter.Height);
pnlOuter.DrawToBitmap(b, new Rectangle(0, 0, pnlOuter.Width, pnlOuter.Height));
b.Save("D:\\bitmapImage.jpg");

pnlOuter is a panel that contains all the controls to be shown in image with extended height to contain all the inner controls. The containing form may have scroll bars enabled.

我通过使用Win API并拍摄了多个屏幕截图,在每个屏幕截图之间滚动然后将它们连接在一起来解决了这个问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM