?
Solved

Getting the font Style from TFontStyle

Posted on 2004-07-30
3
Medium Priority
?
1,179 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
[X]
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
  • 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 1000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

649 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