PrintWindow and Microsoft Edge - windows

we have a problem with the PrintWindow function on Windows 10 (build 10166). 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.
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. We also tried to use BitBlt to copy window's DC to a memory surface, but it's not working too. 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. 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.
I just tried on my machine on Microsoft Edge and Chrome and worked on both.Hope that does the job!

I had the same problem with IE
try this.
The most stable result was with double call
PrintWindow(hWnd, hdcScreen, 0);
PrintWindow(hWnd, hdcScreen, PW_CLIENTONLY);

Related

Screenshot of the specific window (HWND, HW accelerated)

I need to capture a snapshots/screenshots of the specific window (HWND) that is using HW acceleration and record them to a video stream.
While using BitBlt or PrintWindow I'm able to capture image data only if this window is not HW accelerated, else I'm getting a black texture.
Tried using User32.dll's undocumented DwmGetDxSharedSurface to get the DirectX surface handle. But it fails with an error:
ERROR_GRAPHICS_PRESENT_REDIRECTION_DISABLED - desktop windowing
management subsystem is off
(Edit: Fails for certain applications, i.e. "calculator.exe")
Tried using Dwmapi.dll's undocumented functions DwmpDxUpdateWindowSharedSurface and DwmpDxGetWindowSharedSurface. I've managed to retrieve what looks like a valid DirectX surface handle. (it's d3dFormat, width and height information was valid) Dx's OpenSharedResource was not complaining and managed to create a valid ID3D11Texture2D. Problem is.. all bytes are zeros (getting a black texture). I might be doing something wrong here or.. undocumented DWM functionas does not work anymore on Windows 10...
Edit: I'm able to get image data for some applications like Windows
explorer, Paint, etc, but for some like i.e. Slack i get all
zeros/black image.
Edit: When capturing i.e. VLC, I get this:
Question:
Is there any other way to capture image data of the HW accelerated window?
Note: I don't want to capture the entire desktop.
You can use PrintWindow with nFlags=2
Or use Magnification API (exclude windows)
Or try to hack dwm.exe.

X11 graphics context not rendering anything

I've been looking through the Xlib docs attempting to create a simple XWindows application. I'm able to get a window up and running, modify its background colour using pixel colours, etc.
Unfortunately, when I try and create a graphics content and render some of the primitives (Rectangles/Arcs etc) nothing is rendered.
I then built and ran the example here to make sure I wasn't missing something and it also just rendered the background with none of the primitives.
Can anyone explain what I may be missing here?
If it matters I'm running Fedora 23 on kernel 4.4.1 using Gnome shell.
You need to add event loop and move your drawing to occur after you receive expose event ( also make sure you set event mask when you create window or with XSelectInput call ). Likely the result of your drawing is disposed at some point and because you don't react to "window are is damaged, need to re-paint" notification all you see is window background
Take a look at this example

Mirroring a portion of the screen to an external display (in OSX)

I would like to write a program that can mirror a portion of the main display into a new window. Ideally this new window could then be displayed on an external monitor. I have seen this uiltity for a flightsim that does this on a pc (a multifunction display extractor).
CLick here for a screenshot of the program (MFD Extractor)
This would be a live window ie. constantaly updated video display not just a static graphic.
I have looked at screen magnifiers or vnc clients for ideas but I think I need to write something from scratch. I have tried to do some reading on osx programing but where do I start in terms of gaining access to the display? I somehow need to extract the graphics from a particular program. Is it best to go near the final output stage (the individual pixels sent to the display) or somewhere nearer the window management stage.
Any ideas or pointers would be much appreciated. I just need somewhere to start from.
Regards,
There are a few ways to do this:
Quartz Display Services will let you get access to the video memory for a screen.
Quartz Window Services (a.k.a. CGWindow) will let you create an image of everything that lies below a window. If you create a borderless, transparent, empty, high-level window whose frame occupies an entire screen, everything below it will be everything on that screen. (Of course, you could create a smaller window in order to copy a section of the screen.)
There's also a way to do it using OpenGL that I never fully understood. That technique is demonstrated by a couple of code samples, OpenGLScreenSnapshot and OpenGLCaptureToMovie. It's more or less obsoleted by CGWindow, though.
Each of those will get you an image that you can then show or write to a file or something.
To show an image, use NSImageView or IKImageView. If you want to magnify it, IKImageView has a zoomFactor property, but if you want nearest-neighbor scaling (like Pixie, DigitalColor Meter, or xScope), I think you'll need to write a custom view for that (but even that isn't all that hard).

Odd behavior - SWT Browser on Mac OS X

This is a strange behavior, and hard to explain without a picture, so I will try my best.
My application has an embedded SWT browser widget, and the application is cross platform. It works perfect on Windows, but need to support Mac OS X 10.4 and above. The browser widget is within a composite on the right side, and a file tree within another composite is on the left side. The user clicks files from the tree, and they are in turn decrypted and displayed in the browser.
I am testing the app on Mac 10.4.11 currently and this strange behavior happens only when I resize the shell window. The composite and browser widget itself resize properly. I can see the bounds/border of the objects. The problem is the image that is supposed to be within the browser - shifts (almost as if the displayed image is not anchored to the top left corner of the browser). It is aligned top to bottom, and the image itself is the correct size, but the image moves after the resize is done. The app looks fine (meaning the image is aligned perfect) when it initially loads, looks fine when the file tree is hidden and the browser/composite take up the full shell, looks fine when the file tree is restored. It only during resize that this happens.
I hope that made some sense. Any ideas?
Ok i figured it out. Here is what I had at first (in pseudo-code):
webBrowser.setSize(shell.width, shell.height);
webComposite.getParent().layout();
Turns out i needed to pretty much restore the browser and its composite in the same way i did when i restored the file tree (cause i knew it was correctly sized after that action). The code above was replaced with:
webComposite.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true));
webComposite.setBounds(widthOfTreeComposite, 0, shell.width, shell.height);
webComposite.setSize(shell.width, shell.height);
webBrowser.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true));
webBrowser.setBounds(0, 0, shell.width, shell.height);

What is a robust method for capturing screen of child window in Windows 7?

Pardon my frustration. I've asked about this in many places and I seriously don't think that there wouldn't be a way in Windows 7 SDK to accomplish this.
All I want, is to capture part of a 'child window' ( setParent() ) created by a parent. I used to do this with bitblt() but the catch is that the child window can be any type of application, and in my case has OpenGL running in a section of it. If I bitblt() that, then the OGL part comes blank, doesn't get written to the BMP.
DWM, particularly dwmRegisterThumbnail() doesn't allow thumbnail generation of child windows. So please give me a direction.
Thanks.
It's been a while since I did any of this, so my explanation might be a bit vague, but from what I remember, the Windows doesn't "see" the OpenGL rendered inside the window.
What Windows does is create the window at the specified size and then "hands it over" to OpenGL for rendering. This means that you can't get at the pixels as rendered from the Windows side of the code.
When we wanted to capture the 3D we had to re-render the screen to an off screen bitmap which was then saved (or printed).
Obviously a whole screen capture (Print Screen) works because it's reading the final pixels.
I suggest that you:
Forget the Thumbnail part of the task (in terms of capture).
Calculate where your window is.
Capture full screen.
Excise the area you are interested in (using data from step 2).
Rescale to the appropriate thumbnail size.
Sorry, its more work, but it should work, which is better than what you have right now.
This may help:
http://code.google.com/p/telekinesis/source/browse/trunk/Mac/Source/glgrab.c?r=140
http://www.codeproject.com/KB/dialog/screencap.aspx
Also Java's Robot class (http://java.sun.com/javase/6/docs/api/java/awt/Robot.html#createScreenCapture%28java.awt.Rectangle%29)
I don't have access to the source code of any child window that may be open including the one with OpenGL

Resources