Thema: Delphi Suchen einer Methode

Einzelnen Beitrag anzeigen

Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#2

Re: Suchen einer Methode

  Alt 25. Feb 2008, 19:29
Hi,

Das dürfte so funktionieren:

Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Sieben(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var x: TMethod;
begin
  x.Data := Button1; // Der zukünftige Besitzer der Methode
  x.Code := TForm1.MethodAddress('Sieben'); // Pointer zur Methode selbst
  Button1.OnClick := TNotifyEvent(x);
end;

procedure TForm1.Sieben(Sender: TObject);
begin
  ShowMessage('Sieben!');
end;

end.
EDIT: Alles neu gemacht

Gruß
Neutral General
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
  Mit Zitat antworten Zitat