在keydown里面写
if shift = ssCtrl then
begin
if key =vk_Left then else if key= vk_Up else if key= vk_Right else if key=vk_Down
end;
if shift = ssCtrl then
begin
if key =vk_Left then else if key= vk_Up else if key= vk_Right else if key=vk_Down
end;
调试欢乐多
N21.ShortCut:=VK_LWIN+vk_Right ;
..........
回路漫漫:可否给出解释???
而且根本没有用的
[对于上述回复不作正确性保证!]
[我是回来看看你们的~~我想你们~~]
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
case Key of
VK_LWIN, VK_RWIN: FKeyDownWin := True;
VK_LEFT, VK_RIGHT, VK_UP, VK_DOWN:
if FKeyDownWin then
Caption := Format('(Win)Now:%.6f, Key:%d', [Now, Key])
else if Shift = [ssCtrl] then
Caption := Format('(Ctrl)Now:%.6f, Key:%d', [Now, Key])
end;
end;procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
case Key of
VK_LWIN, VK_RWIN: FKeyDownWin := False;
end;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
KeyPreview := True;
end;
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
FHotKeyLeft: Integer;
FHotKeyRight: Integer;
FHotKeyDown: Integer;
FHotKeyUp: Integer;
procedure WMHOTKEY(var Msg: TWMHOTKEY); message WM_HOTKEY;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
if GlobalFindAtom('FHotKeyLeft') <> 0 then Halt;
if GlobalFindAtom('FHotKeyRight') <> 0 then Halt;
if GlobalFindAtom('FHotKeyDown') <> 0 then Halt;
if GlobalFindAtom('FHotKeyUp') <> 0 then Halt;
FHotKeyLeft := GlobalAddAtom('FHotKeyLeft');
RegisterHotKey(Handle, FHotKeyLeft, MOD_CONTROL, VK_LEFT);
FHotKeyRight := GlobalAddAtom('FHotKeyRight');
RegisterHotKey(Handle, FHotKeyRight, MOD_CONTROL, VK_RIGHT);
FHotKeyDown := GlobalAddAtom('FHotKeyDown');
RegisterHotKey(Handle, FHotKeyDown, MOD_CONTROL, VK_DOWN);
FHotKeyUp := GlobalAddAtom('FHotKeyUp');
RegisterHotKey(Handle, FHotKeyUp, MOD_CONTROL, VK_UP);
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
UnRegisterHotKey(Handle, FHotKeyLeft);
UnRegisterHotKey(Handle, FHotKeyRight);
UnRegisterHotKey(Handle, FHotKeyDown);
UnRegisterHotKey(Handle, FHotKeyUp);
GlobalDeleteAtom(FHotKeyLeft);
GlobalDeleteAtom(FHotKeyRight);
GlobalDeleteAtom(FHotKeyDown);
GlobalDeleteAtom(FHotKeyUp);
end;procedure TForm1.WMHOTKEY(var Msg: TWMHOTKEY);
begin
if Msg.HotKey = FHotKeyLeft then
ShowMessage('FHotKeyLeft')
else if Msg.HotKey = FHotKeyRight then
ShowMessage('FHotKeyRight')
else if Msg.HotKey = FHotKeyDown then
ShowMessage('FHotKeyDown')
else if Msg.HotKey = FHotKeyUp then
ShowMessage('FHotKeyUp');
end;end.
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
FHotKeyLeft: Integer;
FHotKeyRight: Integer;
FHotKeyDown: Integer;
FHotKeyUp: Integer;
procedure WMHOTKEY(var Msg: TWMHOTKEY); message WM_HOTKEY;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
if GlobalFindAtom('FHotKeyLeft') <> 0 then Halt;
if GlobalFindAtom('FHotKeyRight') <> 0 then Halt;
if GlobalFindAtom('FHotKeyDown') <> 0 then Halt;
if GlobalFindAtom('FHotKeyUp') <> 0 then Halt;
FHotKeyLeft := GlobalAddAtom('FHotKeyLeft');
RegisterHotKey(Handle, FHotKeyLeft, MOD_WIN, VK_LEFT);
FHotKeyRight := GlobalAddAtom('FHotKeyRight');
RegisterHotKey(Handle, FHotKeyRight, MOD_WIN, VK_RIGHT);
FHotKeyDown := GlobalAddAtom('FHotKeyDown');
RegisterHotKey(Handle, FHotKeyDown, MOD_WIN, VK_DOWN);
FHotKeyUp := GlobalAddAtom('FHotKeyUp');
RegisterHotKey(Handle, FHotKeyUp, MOD_WIN, VK_UP);
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
UnRegisterHotKey(Handle, FHotKeyLeft);
UnRegisterHotKey(Handle, FHotKeyRight);
UnRegisterHotKey(Handle, FHotKeyDown);
UnRegisterHotKey(Handle, FHotKeyUp);
GlobalDeleteAtom(FHotKeyLeft);
GlobalDeleteAtom(FHotKeyRight);
GlobalDeleteAtom(FHotKeyDown);
GlobalDeleteAtom(FHotKeyUp);
end;procedure TForm1.WMHOTKEY(var Msg: TWMHOTKEY);
begin
if Msg.HotKey = FHotKeyLeft then
ShowMessage('FHotKeyLeft')
else if Msg.HotKey = FHotKeyRight then
ShowMessage('FHotKeyRight')
else if Msg.HotKey = FHotKeyDown then
ShowMessage('FHotKeyDown')
else if Msg.HotKey = FHotKeyUp then
ShowMessage('FHotKeyUp');
end;end.