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

📄 unit2.pas

📁 该程序用Delphi实现了一个不错的3D动画播放
💻 PAS
字号:
unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Grids, Buttons;

type
  TForm2 = class(TForm)
    StringGrid1: TStringGrid;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure FormKeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;
  myRect: tgridrect;

  records1:array[1..10,1..3] of string;

implementation

uses Unit1;

{$R *.DFM}

procedure TForm2.FormShow(Sender: TObject);
var f1:textfile;
    i,j:integer;
begin
stringgrid1.Ctl3D:=false;
stringgrid1.GridLineWidth:=1;
stringgrid1.ClientWidth:=stringgrid1.GridWidth;
stringgrid1.ClientHeight:=stringgrid1.GridHeight;
speedbutton1.Left:=0;
speedbutton2.Left:=0;
speedbutton2.Top:=stringgrid1.Height;
speedbutton2.Width:=stringgrid1.Width;
speedbutton1.Top:=stringgrid1.Height+speedbutton2.Height;
speedbutton1.Width:=stringgrid1.Width;

form2.ClientWidth:=stringgrid1.Width;
form2.ClientHeight:=speedbutton1.Top+speedbutton1.Height;
form2.Left:=(screen.Width-form2.Width) div 2;
form2.Top:=(screen.Height-form2.Height) div 2;

assignfile (f1,'records.dat');
reset (f1);
for i:=1 to 10 do begin
    readln(f1,records1[i,1]);
    readln(f1,records1[i,2]);
    readln(f1,records1[i,3]);
end;
closefile(f1);

for i:=1 to 10 do begin
    for j:=1 to 3 do begin
        stringgrid1.Cells[j-1,i-1]:=records1[i,j];
    end;
end;
{myRect.Left := 0;
myRect.Top := 2;
myRect.Right := 1;
myRect.Bottom := 2;
StringGrid1.Selection := myRect;}
end;

procedure TForm2.FormCreate(Sender: TObject);
var i,j:integer;
    f1:textfile;
begin
stringgrid1.ColWidths[0]:=20;
stringgrid1.ColWidths[1]:=200;
stringgrid1.ColWidths[2]:=40;

myRect.Left := 0;
myRect.Top := -1;
myRect.Right := 2;
myRect.Bottom := -1;
StringGrid1.Selection := myRect;

//Creating records file if not exists
if not fileexists('records.dat') then begin
    assignfile (f1,'records.dat');
    rewrite (f1);
    for i:=1 to 10 do begin
        writeln(f1,inttostr(i));
        writeln(f1,'Unknown');
        writeln(f1,'0000');
    end;
    closefile(f1);
end;
////
assignfile (f1,'records.dat');
reset (f1);
for i:=1 to 10 do begin
    readln(f1,records1[i,1]);
    readln(f1,records1[i,2]);
    readln(f1,records1[i,3]);
end;
closefile(f1);

for i:=1 to 10 do begin
    for j:=1 to 3 do begin
        stringgrid1.Cells[j-1,i-1]:=records1[i,j];
    end;
end;


end;

procedure TForm2.SpeedButton1Click(Sender: TObject);
begin
close;
end;

procedure TForm2.SpeedButton2Click(Sender: TObject);
var i,j:integer;
    f1:textfile;
begin
if messagedlg('Are you sure you wanna clear the records?',mtwarning,[mbyes,mbno],0)=mryes then begin
  assignfile (f1,'records.dat');
  rewrite (f1);
  for i:=1 to 10 do begin
    writeln(f1,inttostr(i));
    writeln(f1,'Unknown');
    writeln(f1,'0000');
  end;
  closefile(f1);

  assignfile (f1,'records.dat');
  reset (f1);
  for i:=1 to 10 do begin
    readln(f1,records1[i,1]);
    readln(f1,records1[i,2]);
    readln(f1,records1[i,3]);
  end;
  closefile(f1);

  for i:=1 to 10 do begin
    for j:=1 to 3 do begin
        stringgrid1.Cells[j-1,i-1]:=records1[i,j];
    end;
  end;
end;

end;

procedure TForm2.FormKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then speedbutton1.Click;
end;

end.

⌨️ 快捷键说明

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