Solved

TFont property

Posted on 2001-09-12
4
284 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
Comment Utility
It is impossible
0
 
LVL 8

Accepted Solution

by:
TOndrej earned 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
have a look at TCanvas for example
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now