Question and Answer Database FAQ1719D.txt Trapping the Windows system key 'PrintScreen' Category :Windows API Platform :All Product :All 32 bit Question: How can I globally trap the Windows system key "PrintScreen"? Answer: 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; 7/16/98 4:31:28 PM
Last Modified: 01-SEP-99