Solved

Disabling printscreen

Posted on 1998-08-24
10
905 Views
Last Modified: 2010-04-04
Can anyone show me how to disable the print screen event.
There are two ways I guess, either through Application.OnMessage
or through theWMSysCommand(var message...

I'd like the second since the first would slow the application down.

Please anyone!
0
Comment
Question by:peed112097
  • 4
  • 2
  • 2
  • +2
10 Comments
 
LVL 1

Expert Comment

by:pjdb
ID: 1337514
I think that the print screen does not go to the application since it is handle by the system to copy all the screen.
The only way i see to do it is to hook to the clipboard to be notifyed of he changes and clear it if the content is a copy of the screen.
JDB
0
 

Author Comment

by:peed112097
ID: 1337515
Ok, maby I did'nt make my self clear. I'm not interested in disabling the printscreen, all I want is that when hitting the printscreen key, nothing in my application should be printed.

/Per
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1337516
There is a component in the RXLibrary that can view the clipboard...it might be useful to you in some way ..

Regards,
Viktor Ivanov
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1337517
You might wanna hook the window with the the keyboard hook, and if that key is pressed then do nothing,,,,

Regards,
Viktor Ivanov
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1337518
You might wanna hook the window with the the keyboard hook, and if that key is pressed then do nothing,,,,

Regards,
Viktor Ivanov
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:peed112097
ID: 1337519
Can you show me with an examle on the keyboard hook?
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 50 total points
ID: 1337520
Hi peed,

a Win32 app can register the print key as a hotkey:

 RegisterHotKey (Self.Handle, idHOT_SNAPWINDOW,
                  0, // can use MOD flags here, see win32.hlp
                  VK_SNAPSHOT);

It has to unregister it when it terminates.

  UnRegisterHotKey (Self.Handle, idHOT_SNAPWINDOW);

 
Add a handler for WM_HOTKEY to your main form and you can do something like
this

procedure TForm_MnMain.WMHotKey (Var Message: TWMHotKey);
begin
  If message.HotKey = idHot_SnapWindow then
    MyPrintScreen;
end;

Regards, Zif.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1337521
function KeyBoardCallback (Code : Integer; WParam : Word;
   LParam : Longint) : LongInt;
   begin
     Result := 0;
     // Check to see if it's the hot key ..here is the secret to get the key
   if Lo(wParam) = VK_SNAPSHOT then
     begin
     //Do your code here.....
      ShowMessage('Hot key pressed');
   Result := 1;
   end;
   CallNextHookEx(gHook, code, Wparam, Lparam);
   end;
-==============To hook===============-
   gHook := SetWindowsHookEx(WH_KEYBOARD, @ClueCardKeyBoardCallback,
   HInstance, GetCurrentThreadId);
   If (gHook = 0) then ShowMessage('Not Hooked');
-==============To unhook===============-
   { This unhooks the hook }
   If not(UnHookWindowsHookEx(gHook)) then
   ShowMessage('Couldnt Unhook');
--------------
It would be something similar to this.....I hope it helps =)

Regards,
Viktor Ivanov

0
 
LVL 4

Expert Comment

by:erajoj
ID: 1337522
Here's an example from borland.com:

The PrintScreen system key is not processed during the TForm
keydown event. The following example tests if the PrintScreen key has
been pressed by calling the Windows API function GetAsyncKeyState()
during the Application.OnIdle event.

Example:

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    procedure AppIdle(Sender: TObject; var Done: Boolean);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.OnIdle := AppIdle;
end;

procedure TForm1.AppIdle(Sender: TObject; var Done: Boolean);
begin
  if GetAsyncKeyState(VK_SNAPSHOT) <> 0 then
  Form1.Caption := 'SnapShot';
  Done := True;
end;

/// John
0
 
LVL 4

Expert Comment

by:erajoj
ID: 1337523
And here's another:

The following example demonstrates registering a hot key with the
system to globally trap the windows printscreen key.

Example:

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
    procedure WMHotKey(var Msg : TWMHotKey); message WM_HOTKEY;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

const id_SnapShot = 101;

procedure TForm1.WMHotKey (var Msg : TWMHotKey);
begin
  if Msg.HotKey = id_SnapShot then
  ShowMessage('GotIt');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  RegisterHotKey(Form1.Handle,
    id_SnapShot,
    0,
    VK_SNAPSHOT
  );
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  UnRegisterHotKey (Form1.Handle, id_SnapShot);
end;

/// John

0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now