Autor Beitrag
Basti
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 345

Windows Vista
D2005 Pers, D7 Pers
BeitragVerfasst: So 03.04.05 14:06 
Hallo Leute,
ich möchte einem Array von Edits ein OnClick Ereignis zuweisen.
Funktioniert aber nicht:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
[...]

  private
    { Private-Deklarationen }
    start_lok_Edit:      Array[1..10of TEdit;

[...]

start_lok_Edit[i].OnClick := OnClick_ChooseStartRoot(Self);

[...]

procedure TForm2.OnClick_ChooseStartRoot(Sender: TObject);

[...]


[Fehler] u_formular_einstellungen.pas(248): Inkompatible Typen: 'TNotifyEvent' und 'procedure, untyped pointer or untyped parameter'

Kann mir jemand sagen, wie ich das machen muss?
Vielen Dank

_________________
Der Computer ist die logische Weiterentwicklung des Menschen: Intelligenz ohne Moral.
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: So 03.04.05 14:11 
ausblenden Delphi-Quelltext
1:
start_lok_Edit[i].OnClick := OnClick_ChooseStartRoot;					


Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
wdbee
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 628
Erhaltene Danke: 1



BeitragVerfasst: So 03.04.05 14:12 
Nur den Zeiger (Namen) angeben, nicht die Procedure aufrufen:
ausblenden Delphi-Quelltext
1:
2:
3:
[...]  
start_lok_Edit[i].OnClick := OnClick_ChooseStartRoot;  
[...]
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: So 03.04.05 14:12 
So geht es:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
  private
    procedure myClick(Sender : TObject);
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

{...}

procedure TForm1.FormCreate(Sender: TObject);
begin
  button1.OnClick := myClick;
end;


Wichtig ist, dass myClick eine Methode ist (also zu einem Objekt gehört), denn TNotifyEvent ist als procedure(sender : TObject) of object definiert.

MfG
Christian

//Edit: :motz: zu langsam

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Basti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 345

Windows Vista
D2005 Pers, D7 Pers
BeitragVerfasst: So 03.04.05 15:00 
:shock: So viele Antworten auf einmal!
Danke für die Hilfe.
Ich wusste nicht, dass man die Prozedur dort nicht aufrufen darf - naja - jetzt weiss ich es ;)
THX

_________________
Der Computer ist die logische Weiterentwicklung des Menschen: Intelligenz ohne Moral.