Ver Mensaje Individual
  #5  
Antiguo 13-09-2017
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
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; // Form2

// Hizo click en Form2
procedure TForm1.HuboClickEnForm2(mp: TPoint);
begin
  Label1.Caption := Format('X:%3.d, Y:%3.d', [mp.X, mp.Y]);
end;

// Mostrar Form2 - asignar evento
procedure TForm1.btnShowForm2Click(Sender: TObject);
begin
  Form2.Show; // se supone ya creado
  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
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita