以下随机按键咋没反应?
本帖最后由 冥界3大法王 于 2021-12-27 09:34 编辑{:301_974:}
unit Unit3;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs;
type
TForm3 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure hotykey(var msg: TMessage); message WM_HOTKEY;
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
id1: Integer;
A1: Integer;
implementation
{$R *.dfm}
procedure TForm3.FormCreate(Sender: TObject);
begin
Randomize;
A1 := Random(10);
ShowMessage(IntToStr(A1));
id1 := GlobalAddAtom('hotkey1');
RegisterHotKey(handle, id1, MOD_CONTROL + MOD_SHIFT, Ord(A1));
end;
procedure TForm3.FormDestroy(Sender: TObject);
begin
UnRegisterHotKey(handle, id1);
end;
procedure TForm3.hotykey(var msg: TMessage);
begin
if (GetAsyncKeyState(VK_CONTROL) < 0) and (GetAsyncKeyState(VK_SHIFT) < 0) and (GetAsyncKeyState(Ord(A1)) < 0) then //Ctrl+Shift+随机按键码
ShowMessage('Ctrl+Shift+未知按键');
end;
end.
@bester
@tywolf
@topzhp
@sdzzb
@qeeqeeeq
@pzx521521 @JuncoJet 还一问题,请教先生。{:301_974:} 冥界3大法王 发表于 2021-12-30 18:46
@JuncoJet 还一问题,请教先生。
注册热键delphi不是有热键控件么
页:
[1]