Autor Beitrag
Fingolfin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 20



BeitragVerfasst: So 06.07.03 19:43 
Hallö, ich wollte eigentlich nichts anderes als einer selbstgeschriebenen Komponente ein Property zu verpassen, daß selbst einen TFont beinhaltet. Soweit klappt alles ganz gut, ich kann so ziemlich alles im Objektinspektor einstellen, aber wenn ich direkt den Property-Editor vom Font aufrufe, dort alles einstelle und dann kompiliere, schmiert er mir weg.

ausblenden volle Höhe 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:
unit Title;

interface

uses
 Classes, Graphics;

type

  TTitle=class(TPersistent)
  private
   FText:String;
   FFont:TFont;
  protected
  public
   constructor Create;
   destructor Destroy; override;
  published
   property Text:String read FText write FText;
   property Font:TFont read FFont write FFont;
  end;

implementation

constructor TTitle.Create;
begin
 FFont:=TFont.Create;
end;

destructor TTitle.Destroy;
begin
 FFont.Free;
end;

end.


Diese Unit wird in meiner Komponente aufgerufen, in deren Constructor created und im Destructor wieder freigegeben.

Weiß jemand Rat?

Fingolfin
Tweafis
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 647

WinXP + fbsd
Delphi 5 Prof
BeitragVerfasst: So 06.07.03 20:23 
du musst Create overriden, das problem hatte ich auch...

aber nicht inherited und so vergessen.

_________________
.: Es wird der Tag kommen, an dem wir es nicht mehr ändern können :.
Fingolfin Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 20



BeitragVerfasst: So 06.07.03 20:32 
Danke,

aber ich kann die Create nicht overriden, da Create anscheinend in TPersistent keine virtuelle Methode ist, und um TPersistent komme ich auch in Hinblick auf meine geplante Nutzung nicht drumrum.

:?:

Fingolfin
Fingolfin Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 20



BeitragVerfasst: So 06.07.03 20:51 
Ich hab's gelöst, für alle die es interessiert:

ausblenden 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:
  Title=class(TPersistent)
  private
   FText:String;
   FFont:TFont;
   procedure SetFont(const value:TFont);
  protected
  public
   constructor Create;
   destructor Destroy; override;
   procedure Assign(Source: TPersistent); override;
  published
   property Text:String read FText write FText;
   property Font:TFont read FFont write SetFont;
  end;

procedure TTitle.Assign(Source: TPersistent);
begin
  if Source is TTitle then
  begin
    FFont.Assign(TTitle(Source).Font);
  end
  else
   inherited Assign(Source);
end;

procedure TTitle.SetFont(const value:TFont);
begin
  FFont.Assign(Value);
end;


Bis denn,

Fingolfin