Solved

Getting the font Style from TFontStyle

Posted on 2004-07-30
3
1,114 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

What Security Threats Are You Missing?

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

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

18 Experts available now in Live!

Get 1:1 Help Now