![]() |
AW: Wozu haben Komponenten Namen?
Zitat:
Der Typ der Feldvariablen muss nicht mal der Klasse in der dfm entsprechen, solange beide von TComponent abgeleitet sind.
Delphi-Quellcode:
program FunFact2;
{$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils, System.Classes; type TChild1 = class(TComponent) private FValue: Integer; public property Value: Integer read FValue write FValue; end; TChild2 = class(TComponent) private FValue: Boolean; public property Value: Boolean read FValue write FValue; end; TParent = class(TComponent) published Child: TChild1; end; procedure Main; var parent: TParent; child: TChild2; begin parent := TParent.Create(nil); try child := TChild2.Create(nil); child.Name := 'Child'; child.Value := true; parent.InsertComponent(child); Writeln(Parent.Child.Value); child.Value := false; Writeln(Parent.Child.Value); finally parent.Free; end; end; begin try Main; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; Readln; end. |
AW: Wozu haben Komponenten Namen?
Delphi selbst benötigt den Namen nicht. Viele nutzen ihn aber z.B. um die Komponente über den Namen als String zu finden, mit FindComponent.
|
AW: Wozu haben Komponenten Namen?
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:46 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz