Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

TFont property

Posted on 2001-09-12
4
288 Views
Last Modified: 2013-11-23
Hi
I create component with object property (in particular TFont):

TMyComp = class(TLabel)
private
  FFont: TFont;
  procedure SetFont(Value: TFont);
...........
published
  property Font: TFont read FFont write SetFont;
end;

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

Matter-of-course I create and destroy FFont into constructor and destructor.

Using this component the method SetFont is fired when I peform the next:

......
MyComp.Font := Form1.Font;
......

But how can I make SetFont to be fired in case of:

......
MyComp.Font.Size := 72;
......

It sets MyComp.Font.Size to 72 but I need some others actions to be peformed on this event.

Tanks in advance.
Vasily.



0
Comment
Question by:vterekh
  • 2
4 Comments
 
LVL 6

Expert Comment

by:OlegP
ID: 6478670
It is impossible
0
 
LVL 8

Accepted Solution

by:
TOndrej earned 50 total points
ID: 6478725
If you need notification when the font's changed use OnChange, e.g.:

TMyComp = class(...)
private
  FFont: TFont;

  procedure FontChange(Sender: TObject);
public
  constructor Create(AOwner: TComponent); override;
  destructor Destroy; override;
end;

procedure TMyComp.FontChange(Sender: TObject);
begin
  // do your other actions here
end;

constructor TMyComp.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FFont := TFont.Create;
  FFont := FontChange;
end;

destructor TMyComp.Destroy;
begin
  FFont.OnChange := nil;
  FFont.Free;
  inherited Destroy;
end;
0
 
LVL 1

Author Comment

by:vterekh
ID: 6478758
2 TOndrej

Thanks,
I've been trying to locate this in VCL but unfortunately I missed this technique.
0
 
LVL 8

Expert Comment

by:TOndrej
ID: 6478777
have a look at TCanvas for example
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question