tags:

views:

106

answers:

2

I noticed a few times than when I print-screen while Media Player is running, the content is replaced with a grey rectangle. I've no idea if it's deliberate due to DRM, or some technical issue, but it struck me that being able to deliberately block screen-capture might be a useful feature in some scenarios. I am not looking to fix the problem, but replicate it!

Is there some specific message each HWND gets for print-screen - does Windows do a special repaint or simply dump buffers to the clipboard?

I guess I'd prefer to focus this on Win32 specifically, but as long as it's Windows-related then fine.

+3  A: 

Hi John,

You can register a hotkey, using this method. Register the PrtScr key and your application will receive a message in your WndProc, WM_HOTKEY. Once you recieve that, you can do something to your form to blank out the display, or something else.

That hotkey method should work even if your form is minimised.

Russ C
So basically for a short interval I do something like draw a big box on top of my dialog, and then remove it. Interesting. Is this proven or an idea that _should_ work?
John
Well, good point :)The Hotkey stuff is proven, but blocking out the dialog, that's up for experimentation.
Russ C
@John, registering a hotkey for VK_SNAPSHOT will disable print-screening completely. I thank you in advance for not disturbing the functionality of my operating system.
avakar
Good point, you have to call UnregisterHotKey on closing.
Russ C
I've seen another solution that just detects if printscr was pressed during the normal loop, and just clears the clipboard, don't know how viable that is in win32.
Russ C
All that won't help if the user uses a different program for the screenshot, for example the Snipping Tool, which is supplied with Windows Vista and later. I'd hate any app that blocks screenshots for no reason, especially since the "protection" can be circumvented easily.
OregonGhost
To clarify I wouldn't want to disable screenshots entirely. I might for instance have an app which seeks to stop you taking any digital copy of the text shown... e.g disable copy-paste, blank/blur text in a screenshot. It's an academic exercise so lets leave out the ethical aspect (although pointing out about blocking entire print-screen IS very valid)
John
"you have to call UnregisterHotKey on closing", no, hotkeys will get unregistered automatically when the process gets terminated. However, the print-screen key will not work correctly while the app is running, which from where I'm standing is unacceptable.
avakar
@avakar - this is from MSDN:In Windows XP and previous versions of Windows, if a hot key already exists with the same hWnd and id parameters, it is replaced by the new hot key. In subsequent versions of Windows, if a hot key already exists with the same hWnd and id parameters, it is maintained along with the new hot key. In these versions of Windows, the application must explicitly call UnregisterHotKey to unregister the old hot key.
Russ C
Note "the application must explicitly call UnregisterHotKey to unregister the old hot key"
Russ C
+2  A: 

You have to turn off 'Use overlays' to be able to take a screenshot.

Open Windows Media player. Select "Tools" -> "Options..." from the menu. Click on "Performance" tab. Click on "Advanced..." button. Uncheck "Use overlays" checkbox in the "Video Acceleration" group. Click on "OK" button. Click on "OK" button

Uku Loskit
Totally off-topic but thanks anyway! So it's not a feature-by-design then?
John
The overlay is not being captured in your screenshot because if you hit print, only the desktop is being captured. The video overlay is a hardware feature of your video card. I would imagine that it is rendered directly to the video buffer, so windows doesn't know what's going on there. But in Win7 for example, you will see the contents of your media player even with enabled overlay, because everything is hardware accelerated with Aero enabled and the print function will show you the contents of the video buffer.
humbagumba
+1, quite on-topic as it shows that this is not a DRM feature. Making screen shots cannot be prevented on current Windows versions.
Hans Passant