📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
Timer1: TTimer;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
ScrollBar1: TScrollBar;
Label5: TLabel;
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ScrollBar1Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
tar_time:ttime;
djs,start:boolean;
dx,dy:integer;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
begin
//***********************************//
label2.caption:=datetimetostr(now);
if djs then
label3.caption:=timetostr(tar_time-time);
//*********************************//
if start then
begin
if label4.left+label4.width>form1.clientwidth then dx:=-dx;
if label4.top+label4.height>form1.clientheight then dy:=-dy;
label4.left:=label4.left+dx;
label4.top:=label4.top +dy;
if label4.top<0 then dy:=-dy; //屏幕上端
if label4.left<0 then dx:=-dx; //左端
if(timetostr(tar_time-time)='0:00:00') then
begin
button1.Caption:='开始倒计时';
djs:=false;
start:=false;
end
end
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
djs:=not djs;
if djs then
begin
start:=true;
tar_time:=time+encodetime(0,0,strtoint(edit1.Text),0);
button1.Caption:='停止倒计时';
end
else
begin
start:=false;
button1.Caption:='开始倒计时';
end
end;
procedure TForm1.FormCreate(Sender: TObject);
var d:real;
speed:integer;
begin
//***************/ /
djs:=false;
//*********************************//
speed:=20;
d:=30*pi/180;
dx:=round(speed*cos(d));
dy:=round(speed*sin(d));
button1.Caption:='开始倒计时';
edit1.text:='0';
label3.caption:='0:00:00';
end;
procedure TForm1.ScrollBar1Change(Sender: TObject);
begin
timer1.interval:=scrollbar1.position ;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -