Jump to content
Henry Olive

Prevent Alt or Ctrl + Print Screen

Recommended Posts

I wish everyone a healthy day

 

Is there a away to prevent getting picture of a form ( Prevent Alt or Ctrl Print Screen ) ?

 

Thank You

  • Like 1

Share this post


Link to post

Why?

 

And even if you succeed, i could install screen-snap software like "snagit" or some such.

I have not googled but you would probably install a hook in the OS.

Share this post


Link to post

Maybe using Low Level Keyboard Hooks
MSDN LowLevelKeyboardProc

 

But the thing is, there are more ways to make a Screenshot than just using these Shortcuts, even without third party tools:

  • Microsoft Snipping Tools
  • Windows Key + Shift + S
  • Print and MS Paint to cut the Screenshot

You should ask yourself if you actually need to do this and save yourself the time and money.

Edited by Martin Wienold
  • Like 2

Share this post


Link to post

I've added the ability to print every form everywhere. It hasn't been written about taking a photo of the screen yet. So it's a completely useless effort.

Share this post


Link to post

What if the form shows digital Stamp & Signature ?

My all other forms can make screen shot 

p.s : Even though i have below code on the form's OnCreate

 if dm.UsrRightADMINRIGHT.AsString ='No' then TabSheetStamp.TabVisible:=False;

Edited by Henry Olive

Share this post


Link to post
1 hour ago, Martin Wienold said:

But the thing is, there are more ways to make a Screenshot than just using these Shortcuts, even without third party tools:

  • Microsoft Snipping Tools
  • Windows Key + Shift + S
  • Print and MS Paint to cut the Screenshot
  • Make a photo with your smartphone
  • Like 1
  • Haha 2

Share this post


Link to post

Beside analog copy (smartphone) what cant be stopped (but can be a bit mangled if playing with display Hertz) and hooks to eat keyboard you can prevent digital copies (simple screencapture tools) by using overlay to draw screen or write direct to graphic card buffers.

Simple Screencapture or Print would end with a black screen.

Share this post


Link to post
16 hours ago, Remy Lebeau said:

On Windows 7 and later, you can use SetWindowDisplayAffinity() to specify that you want your Form window to only appear on a monitor display.  That will omit (black) it out in screen captures, etc.

SetWindowDisplayAffinity(Application.MainFormHandle, WDA_MONITOR);

Does do nothing, did I called it wrong?

 

//edit

SetWindowDisplayAffinity(Application.MainFormHandle, WDA_MONITOR or WDA_EXCLUDEFROMCAPTURE);

Also not working.

 

(I called it in FormCreate event)

 

 

Used Capture Software: Screenshot Captor from DonationCoder.com

Tested on latest Windows 10 pro.

Edited by KodeZwerg

Share this post


Link to post
SetWindowDisplayAffinity(Application.MainFormHandle

You really need to be calling this method from CreateWnd because of VCL window recreation. Also it's kinda odd that you would use MainFormHandle from a method of the main form. Why not use Handle? But it's important to move that code to CreateWnd.

  • Thanks 1

Share this post


Link to post
1 hour ago, David Heffernan said:

SetWindowDisplayAffinity(Application.MainFormHandle

You really need to be calling this method from CreateWnd because of VCL window recreation. Also it's kinda odd that you would use MainFormHandle from a method of the main form. Why not use Handle? But it's important to move that code to CreateWnd.

Thank you Mr. Heffernan, that work!

 

type
  TfrmMain = class(TForm)
  protected
    procedure CreateWnd; override;  
  end;

implementation

procedure TfrmMain.CreateWnd;
begin
  inherited CreateWnd;
  SetWindowDisplayAffinity(Handle, WDA_MONITOR);
end;

 

Share this post


Link to post

It's kind of cool that you folks made this work (!). I must quote M$ docs (cannot refrain), but i think you-all are aware.

Quote

This function and GetWindowDisplayAffinity are designed to support the window content protection feature that is new to Windows 7. This feature enables applications to protect their own onscreen window content from being captured or copied through a specific set of public operating system features and APIs. However, it works only when the Desktop Window Manager(DWM) is composing the desktop.

 

It is important to note that unlike a security feature or an implementation of Digital Rights Management (DRM), there is no guarantee that using SetWindowDisplayAffinity and GetWindowDisplayAffinity, and other necessary functions such as DwmIsCompositionEnabled, will strictly protect windowed content, for example where someone takes a photograph of the screen.

I guess teams and such software, when you share a "window" (not the entire desktop) uses this. And it works pretty good for that purpose.

 

There seems to be some confusion in the docs as whether the functionality was created in order to prevent or enhance screen captures:

Quote

One use for this affinity is for windows that show video recording controls, so that the controls are not included in the capture.

Anyway, interesting thread, good to be aware of this. Thanks.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×