Einzelnen Beitrag anzeigen

Crowbar

Registriert seit: 17. Jun 2002
43 Beiträge
 
#8

Re: Über TWinControl an die "Caption"-Bezeichnung?

  Alt 30. Mär 2008, 00:35
Zitat von mkinzler:
Du könntest es vorher mit
if c is TButton then
Ja, so klappt es!
Aber wie ist es, wenn ich das Caption von einer TForm über diese Funktion abrufe?
Man kann ja das TForm verschieden benennen, z.B. MainForm: TMainForm oder Form2: TForm2 usw.

Muß ich, um das Caption der jeweiligen TForm zu ermitteln, anders als
Delphi-Quellcode:
ActiveContrlCaption:=(C as TButton).Caption;
z.B. ActiveFormCaption:=(C as TForm).Caption; <= klappt aber nicht?
vorgehen?

Delphi-Quellcode:
...
FLastActiveControl:=Screen.ActiveControl;
...
i:=0;
C:=FLastActiveControl;
while C <> nil do
 begin
  if (i = 1) then
   begin { Forminfo    }
     ActiveFormClass :=C.ClassName;
     ActiveFormName :=C.Name;
     ActiveFormCaption:= ???
   end
  else
   begin { Controlinfo }
     ActiveContrlClass:=C.ClassName;
     ActiveContrlName :=C.Name;
     if ActiveContrlClass = 'TButtonthen ActiveContrlCaption:=(C as TButton).Caption
   end;
  i:=i+1;
  C:=C.Parent;
 end;
...
... hiermit bin ich soweit, dass diese Funktion (s. oben) alles ausgibt, was ich möchte.
Nur bei dem ermitteln der Caption von der TFrom (ActiveFormCaption) weiß ich nicht weiter.

Gruß
Crowbar
  Mit Zitat antworten Zitat