uMain.pas
资源名称:辩论赛计时器.rar [点击查看]
上传用户:pegasus
上传日期:2013-04-14
资源大小:3825k
文件大小:4k
源码类别:
教育系统应用
开发平台:
Delphi
- unit uMain;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, MPlayer, ExtCtrls, ComCtrls, jpeg, Menus;
- type
- TMainForm = class(TForm)
- mp: TMediaPlayer;
- Image1: TImage;
- MainMenu1: TMainMenu;
- N1: TMenuItem;
- mmiphase1: TMenuItem;
- mmiPhase2: TMenuItem;
- mmiPhase3: TMenuItem;
- mmiPhase4: TMenuItem;
- mmiExit: TMenuItem;
- N7: TMenuItem;
- mmiAbout: TMenuItem;
- procedure FormCreate(Sender: TObject);
- procedure mmiAboutClick(Sender: TObject);
- procedure mmiphase1Click(Sender: TObject);
- procedure mmiPhase2Click(Sender: TObject);
- procedure mmiPhase3Click(Sender: TObject);
- procedure mmiPhase4Click(Sender: TObject);
- procedure mmiExitClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- MainForm: TMainForm;
- ZhFontColor:TColor; //正方计时字体颜色
- FFontColor:TColor; //反方计时字体颜色
- ZhBackgroundColor:TColor; //正方计时字体背景颜色
- FBackgroundColor:TColor; //反方计时字体背景颜色
- procedure beep2; //响两次
- procedure beep1; //响一次
- function IntToTime (IntNum : integer): string; //类型转换
- implementation
- uses
- u1,u2,u3,u4,uAbout;
- {$R *.dfm}
- /////////////////////////////////////////
- //////////////////////////////////////////
- //// 响两声
- // 用TMidiaPlayer播放
- ////////////////////////////////////
- procedure beep2;
- begin
- MainForm.mp.Open;
- MainForm.mp.Play;
- sleep(200); //延时0.2秒
- MainForm.mp.Open ;
- MainForm.mp.Play;
- end;
- /////////////////////////////////////////
- //////////////////////////////////////////
- //// 响一声
- // 用TMidiaPlayer播放
- ////////////////////////////////////
- procedure beep1;
- begin
- MainForm.mp.Open;
- MainForm.mp.Play;
- end;
- //////////////////////////////////////////////
- /////////////////////////////////////////////
- //// 整数转换为时间
- // IntNum :integer 单位为:0.1秒
- // 返回格式: XX分XX秒X
- ////////////////////////////////////////
- function IntToTime (IntNum : integer): string;
- var
- str : string;
- f : integer;
- t : integer;
- begin
- str:= '';
- if intnum > 0 then
- begin
- // first
- f := IntNum div 600;
- t := IntNum mod 600;
- if f > 0 then
- str := str + inttostr( f ) + '分';
- // second
- f := t div 10;
- t := t mod 10;
- if f > 0 then
- str := str + inttostr( f ) + '秒'
- else
- str := str + '00' + '秒';
- //third
- f := t ;
- str := str + inttostr( f ) ;
- end else
- begin
- t := -IntNum ;
- str := ' - ';
- // first
- f := t div 600;
- t := t mod 600;
- if f > 0 then
- str := str + inttostr( f ) + '分';
- // second
- f := t div 10;
- t := t mod 10;
- if f > 0 then
- str := str + inttostr( f ) + '秒'
- else
- str := str + '00' + '秒';
- //third
- f := t ;
- // f := t div 6000;
- str := str + inttostr( f ) ;
- end;
- result := str;
- end;
- ////////////////////////////////////////////////
- ////////////////////////////////////////////////
- //// 读取声音文件
- // 初始化计时字体及背景颜色
- ///////////////////////////////////////////////
- procedure TMainForm.FormCreate(Sender: TObject);
- begin
- if FileExists('ding.wav' ) then
- begin
- mp.FileName:='ding.wav';
- end;
- ZhFontColor:=clRed; //正方计时字体颜色
- FFontColor:=clBlue; //反方计时字体颜色
- ZhBackgroundColor:=clSkyBlue; //正方计时字体背景颜色
- FBackgroundColor:=clYellow;
- end;
- procedure TMainForm.mmiAboutClick(Sender: TObject);
- begin
- with TFormAbout.Create(self) do
- try
- ShowModal;
- finally
- Free;
- end;
- end;
- procedure TMainForm.mmiphase1Click(Sender: TObject);
- begin
- with TForm1.Create(self) do
- try
- ShowModal;
- finally
- Free;
- end;
- end;
- procedure TMainForm.mmiPhase2Click(Sender: TObject);
- begin
- with TForm2.Create(self) do
- try
- ShowModal;
- finally
- Free;
- end;
- end;
- procedure TMainForm.mmiPhase3Click(Sender: TObject);
- begin
- with TForm3.Create(self) do
- try
- ShowModal;
- finally
- Free;
- end;
- end;
- procedure TMainForm.mmiPhase4Click(Sender: TObject);
- begin
- with TForm4.Create(self) do
- try
- ShowModal;
- finally
- Free;
- end;
- end;
- procedure TMainForm.mmiExitClick(Sender: TObject);
- begin
- close;
- end;
- end.