在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;
解决方案 »
- QuickRep求助,如何一个部门打印一页纸...
- gdi+ 在组件中如何用?
- delphi7简单通信问题?
- 一个超难的问题,我已问过“无数高手”,这里是最后的希望了,如何获得“C:\Documents and Settings\Administrator\Local Settings\Tempo
- 谁能帮我看看为什么出现这个错误jpeg error #53
- 有关大量用户在经的服务器的问题
- 请各位指教。。自定义函数该如何声明如何写。请个例子(在线等)
- 推荐一下Delphi的COM编程资料啊
- 向高手求救!
- 请问!如何把DBGrid编辑状态中 的Ctrl+Del按键给屏蔽掉!
- 我用Delphi6编的软件不能用啦,高手请进。
- 如何在程序中实现树节点的移动
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.