Link to home
Start Free TrialLog in
Avatar of QuantumJimbo
QuantumJimbo

asked on

Getting the font Style from TFontStyle

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
Avatar of LMuadDIb
LMuadDIb
Flag of United States of America image

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
ASKER CERTIFIED SOLUTION
Avatar of LMuadDIb
LMuadDIb
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of QuantumJimbo
QuantumJimbo

ASKER

Thats just what I needed to know, Thanks!