⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 本光盘是《Delphi 7应用教程》一书的配套光盘
💻 PAS
字号:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
Type
  MyFont=(st,ls,ht);   //定义枚举类型
var
  ft:MyFont;           //定义枚举类型变量

{$R *.dfm}
Function ffont(fft:MyFont):String;//自定义函数
begin
  Case fft of
    st:ffont:='宋体';
    ls:ffont:='隶书';
    ht:ffont:='黑体';
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if Button1.Caption='宋体' then
    begin
      ft:=st;
      Edit1.Font.Name:=ffont(st);//调用函数,使文本字体变位宋体
    end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  if button2.Caption='隶书' then
    begin
      ft:=ls;
      Edit1.Font.Name:=ffont(ls); //调用函数,使文本字体变为隶书
    end;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  if Button3.Caption='黑体' then
    begin
      ft:=ht;
      Edit1.Font.Name:=ffont(ht);//调用通用函数,使文本字体变为黑体
    end;
end;

end.

⌨️ 快捷键说明

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