unit1.pas

来自「DELPHI经典程序」· PAS 代码 · 共 65 行

PAS
65
字号
unit Unit1;

interface

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

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

var
  Form1: TForm1;

implementation

uses Unit2, Unit3;

{$R *.DFM}
function hasForm(a:String):Boolean;
  var
     x : Integer;
     r : Boolean;
begin
   r := false;
   for x := 0 to Screen.FormCount-1 do
    begin
      if Screen.Forms[x].Name = a then
         r := true;
    end;
   result := r;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  if not hasForm('Form2')then
   begin
     Application.CreateForm(TForm2,Form2);
     ShowMessage('Form2 Create Now');
   end;
  Form2.Show;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  if not hasForm('Form3')then
   begin
     Application.CreateForm(TForm3,Form3);
     ShowMessage('Form3 Create Now');
   end;
  Form3.Show;
end;

end.

⌨️ 快捷键说明

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