Einzelnen Beitrag anzeigen

Thomas F

Registriert seit: 3. Sep 2008
Ort: Nürnberg
281 Beiträge
 
Delphi 2005 Architect
 
#24

Re: Sender soll den Titel des Formulars bestimmen

  Alt 4. Feb 2009, 16:03
Zitat von nahpets:
Hallo,

schonmal mit 'ner ActionList gearbeitet?
Eine Action kann man mehreren Buttons, Menüeinträgen... zuordnen und dort im ActionExecute(Sender: TObject) kann man wunderbar in der gewünschten Form den Sender abfragen. Sender ist hier immer das Control, dass die Action ausgelöst hat.
Delphi-Quellcode:
// procedure TForm4.FormShow(Sender: TObject);
procedure TForm4.Action1Execute(Sender: TObject);
begin
  if Sender = Unit1.Form1.speedbutton9
  then Form4.Caption := ' Eintrag ändern';//Unit4

  if Sender = Unit1.Form1.Speedbutton11
  then Form4.Caption :='Neuer Eintrag';//Unit4

  Form4.Show;
end;
Der Code geht nicht, habs ausprobiert
Form4.show muß in Form1.speedbutton9click aufgerufen werden, sonst erscheint nix

wie wärs mit

Delphi-Quellcode:
const Konstante1: string= 'Neuer Eintrag' ;
Konstante2 :string='Eintrag ändern';

procedure TForm1.SpeedButton9Click(Sender: TObject);
begin
Unit4.Form4.Caption:=Konstante2;
  Unit4.Form4.Show;
end;
procedure TForm1.SpeedButton11Click(Sender: TObject);
begin
Unit4.Form4.Caption:=Konstante1;
  Unit4.Form4.Show;
end;

procedure TForm4.FormShow(Sender: TObject);
begin
if Form4.Caption = Konstante1 then ......

if Form4.Caption = Konstante2 then ......
end;
Gruß

Thomas
  Mit Zitat antworten Zitat