if FontDialog1.Execute then
begin
//如果用户有选取字符串就改变它否则全体字符串都更改
if RichEdit1.SelLength>0 then
RichEdit1.SelAttributes.Assign(FontDialog1.Font)
else
RichEdit1.DefAttributes.Assign(FontDialog1.Font);
end;
end;
if FontDialog1.Execute then
begin
//如果用户有选取字符串就改变它否则全体字符串都更改
if RichEdit1.SelLength>0 then
RichEdit1.SelAttributes.Assign(FontDialog1.Font)
else
RichEdit1.DefAttributes.Assign(FontDialog1.Font);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if fontdialog1.execute then
begin
showmessage(fontdialog1.Font.Name+':'+inttostr(fontdialog1.Font.Size));
end
end;