Solved

How to pass FontDialog1.Font.Name to component variable FontName

Posted on 2007-04-09
2
700 Views
Last Modified: 2008-02-07
Hi everyone,

I made this procedure to pass the fontDialog.Font.Name and Size to
the variable FontName and FontSize stored in my component.

Procedure TMainForm.ChangeFont1Click(Sender: TObject);
begin
 FontDialog1.Font.Name:=MyDrawingPanel1.FontName;
 FontDialog1.Font.Size:=MyDrawingPanel1.FontSize;
  if FontDialog1.Execute() then
    begin
    MyDrawingPanel1.FontName := FontDialog1.Font.Name;
    MyDrawingPanel1.FontSize := FontDialog1.Font.Size;
    end;
end

I get the message:   [Error] Main.pas(346): Undeclared identifier: 'FontName'
                                 [Error] Main.pas(347): Undeclared identifier: 'FontSize'

How can I pass the FontDialog.Font.Name and FontDialog.Font.Size to my
component variables FontName and FontSize?

This is what i have in de contstructor of the component:

  FontName := 'Terminal';
  FontSize := 9;
  Font.Size := FontSize;
  Font.Name := FontName;

Who can help me?

P.
0
Comment
Question by:peterkiers
2 Comments
 
LVL 5

Accepted Solution

by:
xr1140 earned 500 total points
ID: 18876798

make sure FontSize/ FontName are set in your component as public properties
0
 
LVL 1

Author Comment

by:peterkiers
ID: 18876879
I made it like this and it works

procedure TMainForm.ChangeFont1Click(Sender: TObject);
begin
 FontDialog1.Font.Name:=MyDrawingPanel1.FontName;
 FontDialog1.Font.Size:=MyDrawingPanel1.FontSize;
  if FontDialog1.Execute() then
    begin
    MyDrawingPanel1.FontName := FontDialog1.Font.Name;
    MyDrawingPanel1.FontSize := FontDialog1.Font.Size;
    MyDrawingPanel1.Invalidate;
    end;
end;

Thanks
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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

830 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