u4.pas
上传用户:pegasus
上传日期:2013-04-14
资源大小:3825k
文件大小:3k
源码类别:

教育系统应用

开发平台:

Delphi

  1. {****************************************************************** }
  2. {              第四阶段-总结陈辞阶段                                }
  3. {                                                                   }
  4. {****************************************************************** }
  5. unit u4;
  6. interface
  7. uses
  8.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  9.   Dialogs, StdCtrls, ExtCtrls, Buttons, jpeg;
  10. type
  11.   TForm4 = class(TForm)
  12.     Label1: TLabel;
  13.     timer1: TTimer;
  14.     gbZh: TGroupBox;
  15.     sbtnZhStart: TSpeedButton;
  16.     gbF: TGroupBox;
  17.     sbtnFStart: TSpeedButton;
  18.     Timer2: TTimer;
  19.     Image3: TImage;
  20.     lbZh: TLabel;
  21.     ZhLeftTime: TLabel;
  22.     FLeftTime: TLabel;
  23.     lbF: TLabel;
  24.     procedure timer1Timer(Sender: TObject);
  25.     procedure sbtnZhStartClick(Sender: TObject);
  26.     procedure sbtnFStartClick(Sender: TObject);
  27.     procedure Timer2Timer(Sender: TObject);
  28.     procedure FormKeyPress(Sender: TObject; var Key: Char);
  29.     procedure FormCreate(Sender: TObject);
  30.   private
  31.     { Private declarations }
  32.     it :integer;
  33.   public
  34.     { Public declarations }
  35.   end;
  36. var
  37.   Form4: TForm4;
  38. implementation
  39. uses
  40.   uMain;
  41. const
  42.   TM:integer=1800;
  43.   //TM:integer=350;
  44. {$R *.dfm}
  45. procedure TForm4.timer1Timer(Sender: TObject);
  46. begin
  47.   ZhleftTime.Caption:=IntToTime(it);
  48.   if it=300 then
  49.   begin
  50.     beep;
  51.   end;
  52.   if it=0 then
  53.   begin
  54.    uMain.beep2;
  55.   end;
  56.   it:=it-1;
  57. end;
  58. procedure TForm4.sbtnZhStartClick(Sender: TObject);
  59. begin
  60.    case    sbtnZhStart.Tag of
  61.      0:
  62.      begin
  63.        sbtnZhStart.Caption:='停止计时';
  64.        it:=TM;
  65.        timer1.Enabled:=True;
  66.        sbtnZhStart.Tag:=1;
  67.      end;
  68.     1:
  69.      begin
  70.        timer1.Enabled:=False;
  71.        sbtnZhStart.Enabled:=False;
  72.      end;
  73.   end;
  74. end;
  75. procedure TForm4.sbtnFStartClick(Sender: TObject);
  76. begin
  77.   case sbtnFStart.Tag of
  78.     0:
  79.      begin
  80.        sbtnFStart.Caption:='停止计时';
  81.        timer2.Enabled:=True;
  82.        it:=TM;
  83.        sbtnFStart.Tag:=1;
  84.      end;
  85.     1:
  86.      begin
  87.         timer2.Enabled:=False;
  88.         sbtnFStart.Enabled:=False;
  89.          sbtnZhStart.Enabled:=True;
  90.      end;
  91.   end;
  92. end;
  93. procedure TForm4.Timer2Timer(Sender: TObject);
  94. begin
  95.    FleftTime.Caption:=IntToTime(it);
  96.   if it=300 then
  97.   begin
  98.     beep1;
  99.   end;
  100.   if it=0 then
  101.   begin
  102.    uMain.beep2;
  103.   end;
  104.   it:=it-1;
  105. end;
  106. procedure TForm4.FormKeyPress(Sender: TObject; var Key: Char);
  107. begin
  108.  if (Key=#113) or (Key=#81) then
  109.     Close;
  110. end;
  111. procedure TForm4.FormCreate(Sender: TObject);
  112. begin
  113.   it :=1800;
  114.   lbZh.Font.Color:=uMain.ZhFontColor;
  115.   ZhLeftTime.Font.Color:= uMain.ZhFontColor;
  116.   lbF.Font.Color:=uMain.FFontColor;
  117.   FLeftTime.Font.Color:= uMain.FFontColor;
  118.   gbZh.Color:=uMain.ZhBackgroundColor;
  119.   gbF.Color:=uMain.FBackgroundColor;
  120. end;
  121. end.