Autor Beitrag
Tweafis
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 647

WinXP + fbsd
Delphi 5 Prof
BeitragVerfasst: So 29.06.03 15:32 
Ich wollte mein TPanelEx um eine Font erweitern die bei der Überschrift benutzt wird (nicht die normale Font...) Ich hab das jetzt so probiert:

ausblenden 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:
private
  FCaptionFont: TFont;
  procedure SetCaptionFont(const Value: TFont);
  {...}
published
  property CaptionFont: TFont read FCaptionFont write SetCaptionFont;

{...}

// in Create:
  inherited Create(AOwner);
  FCaptionFont := TFont.Create;
  FCaptionFont.Size := 12;
  FCaptionFont.Color := clBlack;

// in Destroy
  FCaptionFont.Free;
  inherited Destroy;

{ ... }
procedure TPanelEx.SetCaptionFont(const Value: TFont);
begin
  FCaptionFont.Assign(Value);
end;


Ich bekomme aber eine Zugriffsverlezung (EAccessViolation) an Adresse xyz.... Was ist da falsch?

//Edit:
Komischerweise aber nur beim Lesen Oo; Wenn ich nicht auslese sondern nur in Create schreibe passiert nichts... Parent gibts ja nicht... Außerdem wüsste ich gern was ich nehmen soll in Create:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
constructor TPanelEx.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FCaptionFont := TFont.Create;
  FCaptionFont.Size := 12;
  FCaptionFont.Color := clBlack;
end;


or

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
constructor TPanelEx.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  CaptionFont := TFont.Create;
  CaptionFont.Size := 12;
  CaptionFont.Color := clBlack;
end;

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

WinXP + fbsd
Delphi 5 Prof
BeitragVerfasst: So 29.06.03 16:57 
Weiß jetzt woran es lag:

Ich hab Create nicht overriden, es wurde nicht aufgerufen und die Font wurde nicht erstellt.
Habs durch die zwei Warnings gemerkt (Create verbirgt die Basismethode...)

_________________
.: Es wird der Tag kommen, an dem wir es nicht mehr ändern können :.