Files
HeidiSQL/source/detours/Demo/DetoursDemo/Delphi/Objects/Demo1/uMain.pas
Ansgar Becker 54a7930045 Clean up:
* remove Detours package, move code to /source/detours/
* remove Detours code from /source/vcl-styles-utils/delphi-detours-library/, so we have only one version
* remove Vcl.FormsFix.pas, as the bugs I fixed with that are most likely fixed with the move to Delphi 10. See https://www.heidisql.com/forum.php?t=19141 for the original bug report.
* only vcl-styles-utils uses the Detours lib from now on
2018-10-30 16:44:48 +01:00

63 lines
1.3 KiB
ObjectPascal

unit uMain;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, DDetours;
type
TMain = class(TForm)
BtnEnableHook: TButton;
BtnDisableHook: TButton;
Edit1: TEdit;
BtnClickMe: TButton;
procedure BtnEnableHookClick(Sender: TObject);
procedure BtnDisableHookClick(Sender: TObject);
procedure BtnClickMeClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Main: TMain;
implementation
{$R *.dfm}
var
TrampolineSetTextBuf: procedure(const Self; Buffer: PChar) = nil;
procedure SetTextBufHooked(const Self; Buffer: PChar);
var
S: String;
begin
S := 'Hooked _' + String(Buffer);
TrampolineSetTextBuf(Self, PChar(S)); // Call the original function .
end;
procedure TMain.BtnDisableHookClick(Sender: TObject);
begin
if Assigned(TrampolineSetTextBuf) then
begin
InterceptRemove(@TrampolineSetTextBuf);
TrampolineSetTextBuf := nil;
end;
end;
procedure TMain.BtnEnableHookClick(Sender: TObject);
begin
Edit1.Text := 'Enter new text ..';
@TrampolineSetTextBuf := InterceptCreate(@TControl.SetTextBuf, @SetTextBufHooked);
end;
procedure TMain.BtnClickMeClick(Sender: TObject);
begin
BtnClickMe.Caption := Edit1.Text;
end;
end.