Autor Beitrag
Sylvus
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 195



BeitragVerfasst: Sa 19.09.09 10:19 
Hay Leute, ich hab ziemlich viele Buttons und will das bei jedem Button den ich drücke die Caption des Buttons ausgegeben wird. Jetzt dachte ich mir ich mach eine procedure:

ausblenden Quelltext
1:
procedure onclickZahl(Sender: TObject);					


und setzte diese Prozedur als OnClick Prozedure bei den ganzen Buttons ein.
In den Procedure wollte ich dann vom Sender die Caption auslesen.

1. Frage:
geht das so?

2. Frage ich bekomme folgenden Fehler:
E2065 Ungenügende Forward- oder External-Deklaration: 'TForm1.onclickZahl'


Vielen Dank
Grüße Sylvus


Moderiert von user profile iconGausi: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am Sa 19.09.2009 um 11:28
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 19.09.09 10:28 
Erstens: Ja, das geht so. :D

Zweitens: Wenn du eine Methode der Form so nennst, dann muss du die auch so implementieren, also

ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.onclickZahl(Sender: TObject);
begin
  // ...
end;

_________________
We are, we were and will not be.
Sylvus Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 195



BeitragVerfasst: Sa 19.09.09 10:35 
ohje ok DANKE :)
noch kurz die folgende Frage, wie komm ich jetzt an die caption des buttons ran?
Sender.Interface ? Vielen DANK!

Grüße Sylvus
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 19.09.09 10:39 
Wenn der Sender immer ein Button ist, dann so:
ausblenden Delphi-Quelltext
1:
myCaption := (Sender as TButton).Caption;					


Wenn nicht, dann sollte man ein if (Sender is TButton) then zusätzlich einbauen.

_________________
We are, we were and will not be.