cmemento.pas

来自「Delphi深度探索,Delphi深度探索(第二版)」· PAS 代码 · 共 73 行

PAS
73
字号
unit CMemento;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    btn1: TButton;
    btn2: TButton;
    procedure btn1Click(Sender: TObject);
    procedure btn2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.btn1Click(Sender: TObject);
begin
  with Self.Canvas do
  begin
    //先用五号宋体写一句话
    Font.Name := '宋体';
    Font.Size := 11;
    textout(100, 100, '宋体五号');
    //再用二号黑体写一句话
    Font.Name := '黑体';
    Font.Size := 22;
    textout(100, 150, '黑体二号');
    //再用五号宋体写一句话
    Font.Name := '宋体';
    Font.Size := 11;
    textout(100, 200, '宋体五号');
  end;
end;

procedure TForm1.btn2Click(Sender: TObject);
var
  FR: TFontRecall;
begin
  with Self.Canvas do
  begin
    //先用五号宋体写一句话
    Font.Name := '宋体';
    Font.Size := 11;
    textout(100, 100, '宋体五号');
    FR := TFontRecall.Create(Font);
    try
      //再用二号黑体写一句话
      Font.Name := '黑体';
      Font.Size := 22;
      textout(100, 150, '黑体二号');
    finally
      FR.Free;
    end;
    //再用五号宋体写一句话
    textout(100, 200, '宋体五号');
  end;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?