Hola.
Otra opción para dectectar un click en Form2 desde Form1, puede ser:
Form1,
Código Delphi
[-]
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
btnShowForm2: TButton;
procedure btnShowForm2Click(Sender: TObject);
private
procedure HuboClickEnForm2(mp: TPoint);
public
end;
var
Form1: TForm1;
implementation {$R *.dfm}
uses Unit2;
procedure TForm1.HuboClickEnForm2(mp: TPoint);
begin
Label1.Caption := Format('X:%3.d, Y:%3.d', [mp.X, mp.Y]);
end;
procedure TForm1.btnShowForm2Click(Sender: TObject);
begin
Form2.Show; Form2.OnClickInForm := HuboClickEnForm2;
end;
end.
Form2,
Código Delphi
[-]
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TClickInForm = procedure(mp: TPoint) of object;
TForm2 = class(TForm)
procedure FormClick(Sender: TObject);
private
FClickInForm: TClickInForm;
public
property OnClickInForm: TClickInForm read FClickInForm write FClickInForm;
end;
var
Form2: TForm2;
implementation {$R *.dfm}
procedure TForm2.FormClick(Sender: TObject);
begin
if Assigned(FClickInForm) then
FClickInForm(ScreenToClient(Mouse.CursorPos));
end;
end.
Salida:
Saludos