unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ieview, imageenview, hyieutils, hyiedefs,
imageenproc;
type
TForm3 =
class(TForm)
ImageEnView1: TImageEnView;
procedure FormKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
procedure FormShow(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormKeyUp(Sender: TObject;
var Key: Word; Shift: TShiftState);
private
{ Private-Deklarationen }
procedure MoveLeft;
public
{ Public-Deklarationen }
end;
var
Form3: TForm3;
KBHook: HHook;
function KeyboardHookProc(Code: Integer; WordParam: Word; LongParam: LongInt): LongInt;
stdcall;
implementation
{$R *.dfm}
function KeyboardHookProc(Code: Integer; WordParam: Word; LongParam: LongInt): LongInt;
stdcall;
var
Key: Word;
begin
case WordParam
of
VK_LEFT:
begin
Key:= WordParam;
LongParam:= 1;
Form3.MoveLeft;
Result:= 0;
Exit;
end;
end;
Result:= CallNextHookEx(KBHook, Code, WordParam, LongParam);
end;
procedure TForm3.FormCreate(Sender: TObject);
begin
inherited ;
KBHook:= SetWindowsHookEx(WH_KEYBOARD,
@KeyboardHookProc, HInstance, GetCurrentThreadId());
end;
procedure TForm3.FormDestroy(Sender: TObject);
begin
UnHookWindowsHookEx(KBHook) ;
end;
procedure TForm3.FormKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
begin
if Key=VK_ESCAPE
then
begin
Close;
end;
if Key=VK_LEFT
then
begin
ShowMessage('
Left');
Key:= 0;
end;
if Key=VK_RIGHT
then
begin
ShowMessage('
Right');
end;
end;
procedure TForm3.FormKeyUp(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
if Key=VK_ESCAPE
then
begin
Close;
end;
if Key=VK_LEFT
then
begin
ShowMessage('
Left');
Key:= 0;
end;
if Key=VK_RIGHT
then
begin
ShowMessage('
Right');
end;
end;
procedure TForm3.FormShow(Sender: TObject);
begin
ImageEnView1.SetFocus;
end;
procedure TForm3.MoveLeft;
begin
ShowMessage('
MoveLeft');
end;
{ MoveLeft }
end.