Autor Beitrag
Bergmann89
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1742
Erhaltene Danke: 72

Win7 x64, Ubuntu 11.10
Delphi 7 Personal, Lazarus/FPC 2.2.4, C, C++, C# (Visual Studio 2010), PHP, Java (Netbeans, Eclipse)
BeitragVerfasst: Fr 12.05.06 09:15 
Hi,

ich will ein Programm sschreiben, indem ich sehr viele Buttons
habe und wo mehrere eigenschaften des Buttons geändert werden
sollen. und da hab'sch mir überlegt da ne Prozedur zu schreiben.
Weiß aber nicht wie ich das anstellen soll.
Hab mir das so gedacht:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
Procedure ButtonCaption(Capt:String; Sender:TObject);
begin
  sender.Create;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
    ButtonCaption('hallo',Button1);
end;


so geht es aber nicht.

Kann mir da ma bitte jemand helfen ?

Thx & MfG Bergmann.
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Fr 12.05.06 09:18 
Wo hängts genau? *Glaskugelsuch*

_________________
Programmers never die, they just GOSUB without RETURN
Bergmann89 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1742
Erhaltene Danke: 72

Win7 x64, Ubuntu 11.10
Delphi 7 Personal, Lazarus/FPC 2.2.4, C, C++, C# (Visual Studio 2010), PHP, Java (Netbeans, Eclipse)
BeitragVerfasst: Fr 12.05.06 09:21 
HI,

ich kann zwar manche befehle von der Variable Sender benutzen,
wie z.B. Sender.Destroy, da verschwindet dann der Button, aber
es sind ebn nicht die eigenschaften dabei, die ein Button normaler
weiße hatt, iwe z.B. die Caption!
Bergmann89 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1742
Erhaltene Danke: 72

Win7 x64, Ubuntu 11.10
Delphi 7 Personal, Lazarus/FPC 2.2.4, C, C++, C# (Visual Studio 2010), PHP, Java (Netbeans, Eclipse)
BeitragVerfasst: Fr 12.05.06 09:23 
habs gefunden !!!
ich muss das nicht als TObject deklarieren,
sondern als TButton.
War noch nicht richtig wach. :lol:

Trotzdem Danke für die Hilfe.

MfG Bergmann
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Fr 12.05.06 09:24 
Klar, weil im Kopf übergibts du ja nur ein TObject. Um Delphi jetzt zu sagen, dass da ein TButton ankommt, benutze sowas:
ausblenden Delphi-Quelltext
1:
(Sender as TButton).Caption := 'Und es geht doch';					


Um zu überprüfen, ob Sender ein TButton ist, kannst du z.B. das hier verwenden:

ausblenden Delphi-Quelltext
1:
if Sender is TButton then ...					


Gruß alias5000

_________________
Programmers never die, they just GOSUB without RETURN
freak4fun
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 604
Erhaltene Danke: 4

Win 7 Pro
VS 2013 Express, Delphi, C#, PHP, Java
BeitragVerfasst: Fr 12.05.06 09:29 
Und wie wäre es mit:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.Button1Click(Sender: TObject);
begin
  if (Sender is TButton) then
    (Sender as TButton).Caption := 'Ich bin ein Button!';
end;


MfG
freak

_________________
"Ich werde auf GAR KEINEN Fall…!" - "Keks?" - "Okay, ich tu's."
i++; // zaehler i um 1 erhoehen
Bergmann89 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1742
Erhaltene Danke: 72

Win7 x64, Ubuntu 11.10
Delphi 7 Personal, Lazarus/FPC 2.2.4, C, C++, C# (Visual Studio 2010), PHP, Java (Netbeans, Eclipse)
BeitragVerfasst: Fr 12.05.06 09:32 
Is auch ne Idee, da kann ich gleich alle Objekte in
einer Procedure bearbeiten.

Vielen Dank.

Man sieht sich,
Bergmann.