Solved

Getting the font Style from TFontStyle

Posted on 2004-07-30
3
1,121 Views
Last Modified: 2013-12-03
Hi,
I'm quite new to Delphi so I expect this is a very n00b question, however how do you retrieve the Bold, Italic etc. settings with TFontStyle from a Font Dialog?
I've tried Form1.TFontDialog1.Font.Style.fsItalic but that doesn't work :(
Also is there a way of getting just the name of the style, like 'Bold' or 'Regular'?
Thanks,
James
0
Comment
Question by:QuantumJimbo
  • 2
3 Comments
 
LVL 4

Expert Comment

by:LMuadDIb
ID: 11682700
simple project, add a single TButton & a TFontDialog to form and add the following to the click event:

procedure TForm1.Button1Click(Sender: TObject);
begin
  if  FontDialog1.Execute then begin
    button1.Font.Name := FontDialog1.Font.Name;
    button1.Font.Color := FontDialog1.Font.Color;
    button1.Font.Size :=  FontDialog1.Font.Size;
    button1.Font.Style := FontDialog1.Font.Style;
  end;

end;

if you just want the FontDialog1 to return text strings instead of TFont properties, you can change them using :
   edit1.text := ColorToString(FontDialog1.Font.Color);
etc... Im not sure what the others wold be though...

hope this helps
0
 
LVL 4

Accepted Solution

by:
LMuadDIb earned 250 total points
ID: 11682733
forgot to mention if you want to know if font style is 'bold' or other you can do this

    if  FontDialog1.Font.Style = [fsBold] then
      showmessage('BOLD');

fsBold
fsItalic
fsUnderline
fsStrikeOut      
0
 

Author Comment

by:QuantumJimbo
ID: 11684940
Thats just what I needed to know, Thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Best Firemonkey component pack 1 85
Source of man or women figure in Text Box 7 99
Deploying Open Type Font (.OTF) company wide ? 3 83
update joined tables 2 24
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 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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

948 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

22 Experts available now in Live!

Get 1:1 Help Now