简体   繁体   English

PrintWindow和Microsoft Edge

[英]PrintWindow and Microsoft Edge

we have a problem with the PrintWindow function on Windows 10 (build 10166). 我们在Windows 10(内部版本10166)上的PrintWindow函数遇到问题。 When we call PrintWindow ( https://msdn.microsoft.com/ru-ru/library/windows/desktop/dd162869(v=vs.85).aspx ) to capture a image of the Microsoft Edge (Project Spartan) browser window we get a black image. 当我们调用PrintWindow( https://msdn.microsoft.com/ru-ru/library/windows/desktop/dd162869 ( v= vs.85).aspx)捕获Microsoft Edge(Project Spartan)浏览器窗口的图像时我们得到黑色图像。

Does anyone know the reason of this and how could it be fixed/avoided? 有谁知道这个的原因以及如何解决/避免它? Or maybe some other way to capture image of a window, that can be in background and hided behind another windows? 还是其他捕获窗口图像的方法,可以在背景中隐藏在另一个窗口后面?

UPDATE : We've tried sending WM_PRINTCLIENT and WM_PRINT messages, and calling DefWindowProc with WM_PRINT, but results are the same - just a black image. 更新 :我们尝试发送WM_PRINTCLIENT和WM_PRINT消息,并使用WM_PRINT调用DefWindowProc,但结果是相同的-只是黑色图像。 We also tried to use BitBlt to copy window's DC to a memory surface, but it's not working too. 我们还尝试使用BitBlt将窗口的DC复制到内存表面,但是它也不起作用。 Best solution that we have now is bringing browser window to foreground, capturing the entire screen and cropping screenshot to window's client size; 我们现在最好的解决方案是将浏览器窗口置于前台,捕获整个屏幕并将屏幕截图裁剪为窗口的客户端大小。 but it can interrupt and annoy users because of switching application that's currently in use. 但是由于切换当前正在使用的应用程序,它可能会打扰和惹恼用户。

If you want to take a screenshot of the page on the browser. 如果要在浏览器上截取页面的屏幕截图。 try this JavaScript library: http://html2canvas.hertzen.com/ The script traverses through the DOM of the page it is loaded on. 请尝试以下JavaScript库: http : //html2canvas.hertzen.com/该脚本遍历加载该脚本的页面的DOM。 It gathers information on all the elements there, which it then uses to build a representation of the page. 它收集那里所有元素的信息,然后将其用于构建页面的表示形式。 In other words, it does not actually take a screenshot of the page, but builds a representation of it based on the properties it reads from the DOM. 换句话说,它实际上并不截取页面的屏幕截图,而是根据它从DOM读取的属性来构建页面的表示形式。

I just tried on my machine on Microsoft Edge and Chrome and worked on both.Hope that does the job! 我刚刚在Microsoft Edge和Chrome上的机器上试用过,并且都可以使用。

I had the same problem with IE try this . 我在IE上遇到了同样的问题,请尝试一下 The most stable result was with double call 最稳定的结果是两次通话

PrintWindow(hWnd, hdcScreen, 0);
PrintWindow(hWnd, hdcScreen, PW_CLIENTONLY);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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