AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Object-Pascal / Delphi-Language Delphi Suche Basisklasse, um Quellcode zu sparen
Thema durchsuchen
Ansicht
Themen-Optionen

Suche Basisklasse, um Quellcode zu sparen

Ein Thema von Christian18 · begonnen am 16. Okt 2007 · letzter Beitrag vom 16. Okt 2007
Antwort Antwort
Christian18

Registriert seit: 9. Dez 2003
Ort: Hamburg
1.279 Beiträge
 
#1

Suche Basisklasse, um Quellcode zu sparen

  Alt 16. Okt 2007, 12:05
Hallo,

gibt es eine Art Basisklasse, damit ich nicht jedes Element extra ansprechen muss?

Delphi-Quellcode:
      // TGroupBox
      if Form.FindComponent(Node.Attributes['Name']) is TGroupBox then
        begin
          (Form.FindComponent(Node.Attributes['Name']) as TGroupBox).Caption:=Node.Attributes['Caption'];
        end;
      // TLabel
      if Form.FindComponent(Node.Attributes['Name']) is TLabel then
        begin
          (Form.FindComponent(Node.Attributes['Name']) as TLabel).Caption:=Node.Attributes['Caption'];
        end;
      // TBitBtn
      if Form.FindComponent(Node.Attributes['Name']) is TBitBtn then
        begin
          (Form.FindComponent(Node.Attributes['Name']) as TBitBtn).Caption:=Node.Attributes['Caption'];
        end;
  Mit Zitat antworten Zitat
Benutzerbild von DeddyH
DeddyH

Registriert seit: 17. Sep 2006
Ort: Barchfeld
27.544 Beiträge
 
Delphi 11 Alexandria
 
#2

Re: Suche Basisklasse, um Quellcode zu sparen

  Alt 16. Okt 2007, 12:08
Versuch es mal mit TControl.
Detlef
"Ich habe Angst vor dem Tag, an dem die Technologie unsere menschlichen Interaktionen übertrumpft. Die Welt wird eine Generation von Idioten bekommen." (Albert Einstein)
Dieser Tag ist längst gekommen
  Mit Zitat antworten Zitat
Progman

Registriert seit: 31. Aug 2007
Ort: 99974 MHL
695 Beiträge
 
Delphi 10.1 Berlin Starter
 
#3

Re: Suche Basisklasse, um Quellcode zu sparen

  Alt 16. Okt 2007, 12:12
Hinweis: Das Array Components enthält alle Komponenten, die sich auf einem Form befinden.
Delphi-Quellcode:
for i := 0 to Self.ComponentCount-1 do begin
  if (Components[i] is TLabel) then //machwas für Label
  if (Components[i] is TButton) then //machwas für Button
// usw:
end;
Karl-Heinz
Populanten von Domizilen mit fragiler, transparenter Aussenstruktur sollten sich von der Translation von gegen Deformierung resistenter Materie distanzieren!
(Wer im Glashaus sitzt sollte nicht mit Steinen werfen)
  Mit Zitat antworten Zitat
Benutzerbild von dataspider
dataspider

Registriert seit: 9. Nov 2003
Ort: 04539 Groitzsch
1.350 Beiträge
 
Delphi 11 Alexandria
 
#4

Re: Suche Basisklasse, um Quellcode zu sparen

  Alt 16. Okt 2007, 13:36
Zitat von DeddyH:
Versuch es mal mit TControl.
Bei TControl ist Caption noch Protected.
Aber man kann ja eine Hilfsklasse erstellen:
Delphi-Quellcode:
THackControl = class(TControl)
published
  property Caption;
end;
Dann könnte man es so lösen:
Delphi-Quellcode:
Var
  AComponent: TComponent;
begin
  AComponent := Form.FindComponent(Node.Attributes['Name']);
  if Assigned(AComponent) then
    THackControl(AComponent).Caption := Node.Attributes['Caption'];
  ...
Frank
Frank Reim
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:38 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz