如何在消息框中使用特定字体? [英] How do I use a specific font in a message box?

查看:76
本文介绍了如何在消息框中使用特定字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Delphi 7的过程中使用特定的字体名称及其大小,如下所示:

How to use a specific font name and its size in a Delphi 7's procedure, like below :

procedure TForm1.infoClick(Sender: TObject);
begin
  ShowMessage(
  '- Lorem ipsum dolor sit amet.'+chr(10)+
  '- Lorem ipsum dolor sit amet.'+chr(10)+
  '- Lorem ipsum dolor sit amet.'
  );
end;

推荐答案

Dialogs 单元中,在 MessageDlg 中使用了函数 CreateMessageDialog:TForm .代码>函数来创建消息表单.您可以在显示表单之前对其进行一些自定义使用:

In the Dialogs unit there is function CreateMessageDialog: TForm used in the MessageDlg function to create message form. You can use it with some customization before form showing:

procedure TForm5.Button1Click(Sender: TObject);
var
  i: Integer;
begin
  with CreateMessageDialog('- Lorem ipsum dolor sit amet.', mtInformation, [mbOk], mbOk) do
  try
    // Sets font for whole form including buttons
    {
    Font.Name := 'Times New Roman';
    Font.Size := 12;
    }
    // Sets font for label(s) only
    for i := 0 to ControlCount - 1 do
      if Controls[i] is TLabel then
        with Controls[i] as TLabel do
        begin
          Font.Name := 'Times New Roman';
          Font.Size := 12;
        end;
    ShowModal;
  finally
    Free;
  end;
end;

这篇关于如何在消息框中使用特定字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆