Solved

Getting the font Style from TFontStyle

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Print Graphic and Text to Epson TM-T88v 12 260
creating threads in delphi 1 106
enhance the following code 3 32
Delphi: sending SMS on android platform 1 21
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

809 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