You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using Delphi 12 right now, and I just created a new vcl project and pasted the code from the demo, and when I click on run, it reports an error : Range check error
I don't know why. It's strange.
I had no problems with Delphi 10 before, is it a Delphi 12 bug?
The code is very simple. copy from demo
unit Unit1;
interfaceuses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, System.Threading, Vcl.StdCtrls, Vcl.ExtCtrls,
Winapi.Hooks;
type
TFormMain = class(TForm)
Button1: TButton;
procedureFormCreate(Sender: TObject);
procedureButton1Click(Sender: TObject);
private{ Private declarations }
FHook: THook;
public{ Public declarations }end;
var
FormMain: TFormMain;
implementation{$R *.dfm}procedureTFormMain.Button1Click(Sender: TObject);
const
Captions: array [Boolean] of string = ('Decativate', 'Active');
begin
FHook.Active := not FHook.Active;
Button1.Caption := Captions[not FHook.Active];
end;
procedureTFormMain.FormCreate(Sender: TObject);
begin
FHook := THookInstance<TLowLevelKeyboardHook>.CreateHook(Self);
FHook.OnPreExecute := procedure(Hook: THook; var HookMsg: THookMessage)
var
LLKeyBoardHook: TLowLevelKeyboardHook;
ScanCode: integer;
begin
LLKeyBoardHook := TLowLevelKeyboardHook(Hook);
if LLKeyBoardHook.LowLevelKeyStates.KeyState <> ksKeyDown then
exit;
ScanCode := LLKeyBoardHook.KeyName.ScanCode;
ifnot(ScanCode in [VK_NUMPAD0 .. VK_NUMPAD9, VK_0 .. VK_9]) thenbegin
Caption := 'Got ya! Key [' + LLKeyBoardHook.KeyName.KeyExtName + '] blocked.';
HookMsg.Result := 1;
endelse
Caption := '';
end;
end;
end.
The text was updated successfully, but these errors were encountered:
I'm using Delphi 12 right now, and I just created a new vcl project and pasted the code from the demo, and when I click on run, it reports an error : Range check error
I don't know why. It's strange.
I had no problems with Delphi 10 before, is it a Delphi 12 bug?
The code is very simple. copy from demo
The text was updated successfully, but these errors were encountered: