网页素材: 导航菜单选项卡滑动门焦点图图片切换下拉菜单弹出层Tabs链接提示

您的当前位置: 源码爱好者 » 网页制作教程(编程教程) » Delphi技术教程

动态效果的delphi随机选号 随机抽取号码

  • 标签:随机生成字符 更新时间:2014-07-31
  • delphi随机生成号码,随机选号,右侧的窗口具备动态效果,让选号程序更加生动,运行截图如下图所示:

    delphi随机选号 随机抽取号码

    Delphi随机选取号码截图

    具体代码:

    unit Unit1;
    interface
    uses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      ExtCtrls, TeEngine, Series, ArrowCha, TeeProcs, Chart, StdCtrls, Buttons;
    type
      TForm1 = class(TForm)
        Chart1: TChart;
        ArrowSeries1: TArrowSeries;
        Timer1: TTimer;
        Panel1: TPanel;
        BitBtn3: TBitBtn;
        Memo1: TMemo;
        Label1: TLabel;
        procedure FormCreate(Sender: TObject);
        procedure Timer1Timer(Sender: TObject);
        procedure BitBtn3Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
        procedure AddRandomArrows;
      end;
    var
      Form1: TForm1;
      data : array[1..15] of Extended;
    implementation
    {$R *.DFM}
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      With ArrowSeries1 do
      Begin
        ArrowWidth:=32;
        ArrowHeight:=24;
        ColorEachPoint:=True;
        XValues.DateTime:=False;
        YValues.DateTime:=False;
        AddRandomArrows;
      end;
    end;
    procedure TForm1.AddRandomArrows;
    var x0,y0,x1,y1:Double;
        t:Longint;
    begin
      With ArrowSeries1 do
      Begin
        Clear;
        for t:=1 to 15 do
        begin
          x0:=Random( 1000 );
          y0:=Random( 1000 );
          x1:=Random( 300 ) - 150.0;
          if x1<50 then x1:=50;
          x1:=x1+x0;
          y1:=Random( 300 ) - 150.0;
          if y1<50 then y1:=50;
          y1:=y1+y0;
          AddArrow( x0,y0,x1,y1, '', clTeeColor );
        end;
      end;
    end;
    procedure TForm1.Timer1Timer(Sender: TObject);
    var t:Longint;
    begin
      Timer1.Enabled:=False;
      With ArrowSeries1 do
      Begin
        for t:=0 to Count-1 do
        Begin
          StartXValues[t]:=StartXValues[t]+Random(100)-50.0;
          StartYValues[t]:=StartYValues[t]+Random(100)-50.0;
          EndXValues[t]  :=EndXValues[t]+Random(100)-50.0;
          EndYValues[t]  :=EndYValues[t]+Random(100)-50.0;
          data[t+1] := StartXValues[t]+StartYValues[t]+EndXValues[t]+EndYValues[t];
        End;
        Repaint;
      End;
      Timer1.Enabled:=True;
    end;
    procedure TForm1.BitBtn3Click(Sender: TObject);
    var
      t,d : integer;
      str : string;
    begin
      if Timer1.Enabled then
      begin
         Timer1.Enabled := False;
         BitBtn3.Caption := '开始';
         for t:=1 to 15 do
         begin
            d := abs(round(data[t])mod 10);
            str := '第'+IntToStr(t)+'位:'+IntToStr(d);
            Memo1.Lines.Add(str);
         end;
      end
      else
      begin
         Timer1.Enabled := True;
         BitBtn3.Caption := '结束';
      end;
    end;
    end.

    完整代码:Delphi随机选号程序

  • 已读: 次 收藏本文关闭本文打印本文复制链接
处理 SSI 文件时出错