打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
delphi实现js效果的滚动
//**********begin**********
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Label1: TLabel;
    Button1: TButton;
    Edit1: TEdit;
    Timer1: TTimer;
    Timer2: TTimer;
    procedure FormShow(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  a,b,c,d,e:integer;
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
 timer1.Enabled := false;
 if edit1.Text <> '' then
  begin
    a := Panel1.Width ;
    Label1.Left := a ;
    Label1.Caption := edit1.Text ;
    b := Label1.Width div 2 ;
    c := Panel1.Width div 2 ;
    d := c - b ;
    e := 0;
    timer1.Enabled := true;
  end;
end;

procedure TForm1.FormShow(Sender: TObject);
begin
 edit1.Clear;
 Label1.Caption := '';
 Panel1.Caption := '';
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
 if a = 0-Label1.Width then
  begin
   a := Panel1.Width ;
  end
 else
  begin
   if (a = d) and (e = 0) then
    begin
     e := 1;
     timer2.Enabled := true;
     timer1.Enabled := false;
    end
   else
    begin
     a := a-1 ;
     e := 0;
     Label1.Left := a ;
     edit1.Text := inttostr(a);
    end;
  end;
end;

procedure TForm1.Timer2Timer(Sender: TObject);
begin
 timer1.Enabled := true;
 Timer2.Enabled := false;
end;

end.

//**********end**********
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
GetForegroundWindow 与 GetActiveWindow 的区别
delphi 截取被遮挡的Window画面
Delphi 7 中的随机函数
问题详情
[转]xe6 android 使用距离传感器(Proximiry)
【转】怎么检测用户多长时间没有鼠标与键盘操作
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服