Delphi-PRAXiS
Seite 3 von 3     123   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Komponente benützt ParentFont und soll Font.Style und Font.Color überschreiben (https://www.delphipraxis.net/165832-komponente-benuetzt-parentfont-und-soll-font-style-und-font-color-ueberschreiben.html)

himitsu 18. Jan 2012 14:59

AW: Komponente benützt ParentFont und soll Font.Style und Font.Color überschreiben
 
Man kann ja in das Create am Ende ein
Delphi-Quellcode:
if not Assigned(Owner) or not (csLoading in Owner.ComponentStyle) then Load;
in Oncreate legen, bzw. auch noch beim Ändern des Parent den Font des Parent auslesen und danach Style neu setzen.

irmdaen 18. Jan 2012 15:05

AW: Komponente benützt ParentFont und soll Font.Style und Font.Color überschreiben
 
Zitat:

Zitat von DeddyH (Beitrag 1146481)
Entweder es hat dieselbe Schrift wie der Parent oder eben nicht. Wenn Du zuerst sagst "Ja, hat es" und dann nachträglich die Schrift änderst, ist es ja wieder eine andere als die des Parents. Von daher ist das Verhalten ja nur logisch und richtig.

[edit] Schnell zusammengeschustert und nicht sonderlich schön, tut aber:
Delphi-Quellcode:
type
  TTestLabel = class(StdCtrls.TLabel)
  protected
    procedure Paint; override;
  end;

...

procedure TTestLabel.Paint;
begin
  Canvas.Font.Assign(Font);
  Canvas.Font.Style := Canvas.Font.Style + [fsBold, fsUnderLine];
  Canvas.Brush.Style := bsClear;
  Canvas.Font.Color := clNavy;
  if AutoSize then
    Width := Canvas.TextWidth(Caption);
  Canvas.TextOut(0, 0, Caption);
end;
[/edit]

Herzlichen Dank!! Ich fasse es nicht, das ist genau was ich mir vorgestellt habe :lol:

DeddyH 18. Jan 2012 15:08

AW: Komponente benützt ParentFont und soll Font.Style und Font.Color überschreiben
 
Zitat:

Zitat von himitsu (Beitrag 1146509)
Man kann ja in das Create am Ende ein
Delphi-Quellcode:
if not Assigned(Owner) or not (csLoading in Owner.ComponentStyle) then Load;
in Oncreate legen, bzw. auch noch beim Ändern des Parent den Font des Parent auslesen und danach Style neu setzen.

[OT] Oder man leitet sich ein Formular ab, weil man einen Link möchte :stupid: [/OT] So, nu isses aber genug, ich klinke mich aus.


Alle Zeitangaben in WEZ +1. Es ist jetzt 15:36 Uhr.
Seite 3 von 3     123   

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