unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;
type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Timer1: TTimer;
    function GetTickCount(): Integer;
    constructor Create (AoWer : TComponent);
    procedure Button1Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    mTime : Integer  ;
    VarPoint : Integer;
  end;
var
  Form1: TForm1;
implementation
 constructor TForm1.Create (AoWer : TComponent);
 begin
 mTime := 0 ;
 end;
{$R *.dfm}
function TForm1.GetTickCount(): Integer;
begin
Randomize;
Random (500);
if Result < 100 then
        Result := 100;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
  Timer1.Enabled := True ;end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
  mTime := mTime + 1 ;
 if Timer1.Tag = 1 then   // 我把这句话变成  if (0 <= mTime - GetTickCount)  and (Timer1.Tag = 0) then 那么系统就没有反应了,如果不加,那么 label6.caption的值就为 -9700000多呀! 怎么回事?能告诉我为什么嘛?
   begin
   Label6.Caption := '' ;  // 为什么当我运行的时候,他还是原来的数值!而不是空的?
   Timer1.Tag := 0;
   end;
 if Timer1.Tag = 0 then
   begin
   Label6.Caption := IntToStr(mTime - GetTickCount()  );
   Form1.Color := clAqua ;
   end;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
  Timer1.Enabled := False ;
  Timer1.Tag := 1 ;end;end.
请高手们赐教!! 拜托了!!

解决方案 »

  1.   

    发错了!应该是:
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls, StdCtrls;
    type
      TForm1 = class(TForm)
        Button1: TButton;
        Button2: TButton;
        Label1: TLabel;
        Label2: TLabel;
        Label3: TLabel;
        Label4: TLabel;
        Label5: TLabel;
        Label6: TLabel;
        Timer1: TTimer;
        function GetTickCount(): Integer;
        constructor Create (AoWer : TComponent);
        procedure Button1Click(Sender: TObject);
        procedure Timer1Timer(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
        mTime : Integer  ;
        VarPoint : Integer;
      end;
    var
      Form1: TForm1;
    implementation
     constructor TForm1.Create (AoWer : TComponent);
     begin
     mTime := 0 ;
     end;
    {$R *.dfm}
    function TForm1.GetTickCount(): Integer;
    begin
    Randomize;
    Random (500);
    if Result < 100 then
            Result := 100;
    end;
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      Timer1.Enabled := True ;end;
    procedure TForm1.Timer1Timer(Sender: TObject);
    begin
      mTime := mTime + 1 ;
     if Timer1.Tag = 1 then   
       begin
       Label6.Caption := '' ;  // 为什么当我运行的时候,他还是原来的数值!而不是空的?
       Timer1.Tag := 0;
       end;
     if Timer1.Tag = 0 then  // 我把这句话变成  if (0 <= mTime - GetTickCount)  and (Timer1.Tag = 0) then 那么系统就没有反应了,如果不加,那么 label6.caption的值就为 -9700000多呀! 怎么回事?能告诉我为什么嘛?
       begin
       Label6.Caption := IntToStr(mTime - GetTickCount()  );
       Form1.Color := clAqua ;
       end;
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
      Timer1.Enabled := False ;
      Timer1.Tag := 1 ;end;end.
    请高手们赐教!! 拜托了!!
      

  2.   

    procedure TForm1.Timer1Timer(Sender: TObject);
    begin
      mTime := mTime + 1 ;
     if Timer1.Tag = 1 then   
       begin
       Label6.Caption := '' ;  // 为什么当我运行的时候,他还是原来的数值!而不是空的?
       Timer1.Tag := 0;
       end
    else if Timer1.Tag = 0 then
       begin
       Label6.Caption := IntToStr(mTime - GetTickCount()  );
       Form1.Color := clAqua ;
       end;
    end;
      

  3.   

    if Timer1.Tag = 0 then  // 我把这句话变成  if (0 <= mTime - GetTickCount)  and (Timer1.Tag = 0) then 那么系统就没有反应了,如果不加,那么 label6.caption的值就为 -9700000多呀! 怎么回事?能告诉我为什么嘛?
       begin
       Label6.Caption := IntToStr(mTime - GetTickCount()  );
       Form1.Color := clAqua ;
       end;
    end;
      

  4.   

    procedure TForm1.Timer1Timer(Sender: TObject);
    begin
      mTime := mTime + 1 ;
     if Timer1.Tag = 1 then   
       begin
       Label6.Caption := '' ;  // 为什么当我运行的时候,他还是原来的数值!而不是空的?
       Timer1.Tag := 0;
       end
    else if Timer1.Tag = 0 then
       begin
       Label6.Caption := IntToStr(mTime - GetTickCount()  );
       Form1.Color := clAqua ;
       end;
    end;换成这个也不行呀!!