I'm having a problem with Delphi XE to access in designtime a read-only property derived from another component only in cases where the component in question it is a specialized form or datamodule.
I have a "Comp1" component and a "Comp2". In "Comp2" component, have a published reading "Comp1" only property.
Plant the "Comp1" component in the "Form1". I specialize "Form1" generating "Form2". If I try to access the "Comp1" property in "Form2" it creates an "Access Violation".
Only identified this problem in Delphi XE. In Delphi 6, tested and works normally. I did not actually test on newer versions XE3, XE4 or XE5.
In the code below I show the case.
Unit UnTestComp;
Interface
Uses Classes, StdCtrls;
Type
//Component 1
TComp1 = Class(TComponent)
Private
FNome: String;
FEdit: TEdit;
Function GetText: String;
Procedure SetText(Const Value: String);
Public
Constructor Create(AOwner: TComponent); Override;
Destructor Destroy; Override;
Published
Property Nome: String Read FNome Write FNome;
Property Texto: String Read GetText Write SetText;
End;
// Component 2
TComp2 = Class(TComponent)
Private
FComp1: TComp1;
Protected
Public
Constructor Create(AOwner: TComponent); Override;
Destructor Destroy; Override;
Published
Property Comp1: TComp1 Read FComp1;
End;
Procedure Register;
Implementation
Uses SysUtils, Dialogs;
Procedure Register;
Begin
RegisterComponents('CompReadOnly Test', [TComp1, TComp2]);
End;
{ TComp1 }
Constructor TComp1.Create(AOwner: TComponent);
Begin
Inherited;
FEdit := TEdit.Create(Self);
End;
Destructor TComp1.Destroy;
Begin
FreeAndNil(FEdit);
Inherited;
End;
Function TComp1.GetText: String;
Begin
Result := FEdit.Text;
End;
Procedure TComp1.SetText(Const Value: String);
Begin
FEdit.Text := Value;
End;
{ TComp2 }
Constructor TComp2.Create(AOwner: TComponent);
Begin
Inherited;
FComp1 := TComp1.Create(Self);
FComp1.Name := 'Comp1';
End;
Destructor TComp2.Destroy;
Begin
FreeAndNil(FComp1);
Inherited;
End;
End.
Someone had a similar problem that can share a possible solution?