Autor Beitrag
Daniel L.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 140
Erhaltene Danke: 14

W7, W8
TurboD Prof, Delphi Community
BeitragVerfasst: Mo 21.02.11 16:50 
Hallo,

ich möchte eine Komponente schreiben, die u. a. eine andere visuelle Komponente beinhaltet.
Diese soll im Objektinspektor der Hautpkomponente als Eigenschaft ansprechbar sein.

(Ich glaube, man sagt dazu auch Objekt-Eigenschaft?)


Als Beispiel : TEdit mit TPanel als Container.
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
unit test;

interface

uses SysUtils, Classes, StdCtrls, ExtCtrls;

type
  TTest = class (TPanel)
  private
    FEdit : TEdit;
  protected
  public
    constructor Create (AOwner : TComponent); override;
  published
    property Edit : TEdit read FEdit write FEdit;
end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Samples', [TTest]);
end;

constructor TTest.Create (AOwner: TComponent);
begin
  inherited;
  FEdit := TEdit.Create (AOwner);
  FEdit.Parent := self;
end;

end.

Es lässt sich zwar kompilieren, bzw. als Komponente installieren,
aber bei Ausführung kommt die Fehlermeldung "EClassNotFound - Klasse TEdit nicht gefunden'

Danke für Eure Hilfe, Gruss: Daniel
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 21.02.11 16:53 
Du hast das RegisterClass für TEdit vergessen. ;-)
Daniel L. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 140
Erhaltene Danke: 14

W7, W8
TurboD Prof, Delphi Community
BeitragVerfasst: Mo 21.02.11 17:41 
hm, ich habe jetzt am Ende folgendes ergänzt:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
unit test;

interface

uses SysUtils, Classes, StdCtrls, ExtCtrls;

type
  TTest = class (TPanel)
  private
    FEdit : TEdit;
  protected
  public
    constructor Create (AOwner : TComponent); override;
  published


    property Edit : TEdit read FEdit write FEdit;
    { Published-Deklarationen }
  end;

procedure Register;


implementation

procedure Register;
begin
  RegisterComponents('Samples', [TTest]);
end;

constructor TTest.Create (AOwner: TComponent);
begin
  inherited;
  FEdit := TEdit.Create (AOwner);
//  FEdit.Name := 'Edit';
  FEdit.Parent := self;
end;

initialization

RegisterClass (TEdit);

end.


Danach hat es *ein*mal funktioniert, danach wieder die gleiche Fehlermeldung.
So ganz versteh ich nicht, was da los ist :?!?:
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 21.02.11 17:56 
Probiere es einmal in der Prozedur Register zusätzlich. Sonst muss ich zu Hause einmal kurz schauen, da gab es in den alten Versionen teilweise noch Fehler. In XE genügt der Code, da bin ich mir sicher.
Daniel L. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 140
Erhaltene Danke: 14

W7, W8
TurboD Prof, Delphi Community
BeitragVerfasst: Mo 21.02.11 18:00 
Irrtum meinerseits, es geht doch wie oben gepostet. :lol:

Danke für Deine Hilfe!