Correction to my previous reply.

Use VK_SNAPSHOT, that is the virtual key code of the PrtSc key.

Here is a reply from Peter Below that may help:

THe key is part of a set that will be processed by the OS, not by your
application. MS has two strategies for such keys. The first is to hand the
key
to the application and do the default processing for it in the default
window
proc that is supposed to get all messages not handled in application code.
The
second is to handle the key on a lower level (between keyboard driver and
message queue, or in the keyboard driver), which means the application never
sees it. Keys in the first category you would see, at least if you look for
them in Application.OnMessage, since the active control normally does not
want
to see all keys. Keys in the second category you never see, not even in a
message hook.

VK_SNAPSHOT seems to fall into the second category, it does not turn up in
Application.OnMEssage. There is a way to get notified of it, however: make
it
a hotkey for your application.

Example:

Using PrintScr to print a form

type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
  private
    { Private declarations }
    procedure wmHotkey( Var msg: TWMHotkey );
      message WM_HOTKEY;
    procedure WMActivate( Var msg: TWMActivate );
      message WM_ACTIVATE;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure tform1.wmHotkey( Var msg: TWMHotkey );
begin
  if msg.HotKey = IDHOT_SNAPWINDOW Then
    label1.caption := 'PrintScr pressed';
    // would print form from here
end;

procedure TForm1.WMActivate( Var msg: TWMActivate );
begin
  If msg.Active <> WA_INACTIVE Then
    RegisterHotkey( Handle, IDHOT_SNAPWINDOW, 0, VK_SNAPSHOT )
  Else begin
    UnRegisterHotkey( Handle, IDHOT_SNAPWINDOW );
    label1.caption := '';
  end;
  inherited;
end;


----- Original Message ----- 
From: "Whitehat" <[EMAIL PROTECTED]>
To: "Delphi-Talk" <delphi-talk@elists.org>
Sent: Wednesday, October 04, 2006 8:09 AM
Subject: PrintScreen Key


> How do you capture the PrintScreen key?
> __________________________________________________
> Delphi-Talk mailing list -> Delphi-Talk@elists.org
> http://www.elists.org/mailman/listinfo/delphi-talk
>


__________________________________________________
Delphi-Talk mailing list -> Delphi-Talk@elists.org
http://www.elists.org/mailman/listinfo/delphi-talk

Reply via email to