Use Delphi to make a sound analog alarm with sound

zhaozj2021-02-11  174

Hi guys. I am a dream, this is my first post, please encourage you to encourage, more support, after all, it is convenient to make it easy. OK, transfer to the topic, and now how to make a table-like clock with a sound. First we should choose to create a new program and add the following components in the form: Timer1: Ttimer; Image1: Timage; // Clock Dial EDIT1: TEDIT; // Date Box Label1: TLabel; PopupMenu1: TpopupMenu; then {$ R * .dfm} The following is added to the {$ r clocksou.res} <- the sound file of the clock, (Note: clocksou.res is new files to create a new file with Windows, add the following line ClickBEL WAVE CLICKBEL .Wav "Timebell Wave" Timebell.wav "is connected to the file clocksou.rc and then compiles clocksou.rc to delphi format with BRCC32.exe under the DOS DOS. Of course, if you are too annoying, you are too annoying. The simplest, to my home page http://www.suye.8u8.com Download the full program code) OK, we can enter the following code in the form of the form after completing the above steps. Unit unit1;

Interface

uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, unit2, StdCtrls, inifiles, MMSystem, Menus; type TForm1 = class (TForm) Timer1: TTimer; Image1: TImage; Edit1: TEdit; Label1: TLabel; PopupMenu1: TPopupMenu; pop1: TMenuItem; pop2: TMenuItem; pop4: TMenuItem; pop3: TMenuItem; pop5: TMenuItem; N1: TMenuItem; procedure Timer1Timer (Sender: TObject); procedure timdrow (tim: real; long, col: integer ); procedure FormCreate (Sender: TObject); procedure Image1Click (Sender: TObject); procedure pop1Click (Sender: TObject); procedure pop2Click (Sender: TObject); procedure pop4Click (Sender: TObject); procedure pop5Click (Sender: TObject); Procedure Pop3Click (Sender: TOBJECT); Procedure TiniWr (); Procedure FormClose (Sender: TpoBject; VAR Action: Tclosection); Procedure N1Click (Sender: Tobject);

PRIVATE {private declarations}

Var Form1: TForm1; Clockbell, WID, POFSE: Integer; TIM1, TIM2, TIM3, TIM4: REAL; DTME: TDATETIME; TIMINI: TINIFILE; DTIM, TEXTDEF, TINIFILE; DTIM, TEXTDEF, TIMFILENAME: STRING; Implementation {$ r * .dfm} {$ R LL1.RES} // Clock's Vocation file procedure tform1.tiniwr (); begintimini: = tinifile.create (TMFileName); with timini dobeginwritestring ('content', 'text', textdef); WritestRing ('parameter', 'time ', dtim); WriteBool (' parameter ',' reports ", pop1.checked); WriteBool ('parameter', 'second sound allowed" POP2.CHECKED); WriteBool (' parameter ',' timing allowed "POP3 . CHECKED); END; TIMINI.FREE;

Procedure TFORM1.TIMDROW (TIM: REAL; long, col: integer); / / The process function of the pointer. VAR XX, YY: Integer; VTT, VT: REAL; Beginif (TIM2 = 59) and (TIM3 = 0) THEN TIM: = TIM-1; if (COL = 3) or (col = 6) Then IF COL = 3 THEN VT: = TIM1 * 5 (TIM2 / 720) ELSE BEGIN VT: = TIM1 * 5 ((TIM2-1) / 720); col: = 5; ELSE VT: = TIM; VT: = Pi-Pi * VT / 30-2 * pi * (VT-15); // De (LONG * SIN (VT)) 45; // denotes the X coordinate XX at the end of the pointer end. = STRTOINT (FLOATTOSTR (VTT)); VTT: = INT (LONG * COS (VT)) 45; YY: = STRTOINT (FLOATTOSTR (VTT)); Case COL OF / / Judgment The pointer to be drawn is a minute, second hand or Hethers 0: beginimage1.canvas.pen.color: = CLGRAY; image1.canvas.pen.width: = 1; end; 1: beginimage1.canvas.pen.color: = CLRED; image1.canvas.pen.width: = 1 End; 2: beginimage1.canvas.pen.color: = CLBLUE; image1.canvas.pen.width: = 2; end; 3: beginimage1.canvas.pen.color: = CLGreen; Image1.canvas.pen.width: = 2; end; 4: beginimage1.canvas.pen.color: = clbanvas.pen.color: = CLBLACK; image1.canvas.pen.width: = 1; end; 5: beginimage1.canvas.pen.color: = CLGRAY; image1.canvas.pen. Width: = 3; End; end; image1.canvas.ellipse (43, 43, 47, 47); image1.canvas.moveto (45, 45); image1.canvas.lineto (xx, yy);

Procedure TForm1.Timer1Timer (Sender: Tobject); Var str1, str2: string; beginstr1: = Timetostr (Time ()); str2: = Copy (STR1, 2, 1); if str2 = ':' Then Pofse: = 0 Else Pofse: = 1; edit1.text: = '' datetostr (date ()); // Date data on the date disc Str2: = Copy (STR1, POFSE 6, 2); TIM4: = STRTOFLOAT (STR2) IF TIM4 <> TIM3 THEN / / Decision Did the Time Beginif (TIM3 = 0) OR (TIM3 = 3) or (TIM3 = 45) or Timdrow (TIM3 = 45) t Timdrow (TIM3 = 45) Else Timdrow (TIM3, 39, 0); TIM3: = TIM4; if Pop2.checked The Plays (Pchar ('ClickBEL'), Hinstance, SND_ASYNC OR SND_RESOURCE); // Second "Tick" Sound Str2: = Copy (STR1, 1, POFSE 1); if (TIM3 = 0) and (TIM2 = 59) THEN / / Decision Did the Time Begin Clockbell: = StrtOINT (STR2); if ClockBell = 0 THEN CLOCKBELL = 0 THEN CLOCKBELL : = 12; End; if ClockBell> 12 The ClockBell: = ClockBell-12; Timdrow (TIM1, 26, 6); TIM1: = STRTOFLOAT (STR2); Timdrow (TIM2, 33, 5); str2: = Copy (STR1 , POFSE 3, 2); TIM2: = STRTOFLOAT (STR2); Timdrow (TIM2, 33, 2); IF (TIM2 <> 59) And (TIM4 <> 0) Timdrow (TIM1-1, 26, 3) Else Timdrow (TIM1, 26, 3); TIM2: = STRTOFLOAT (STR2); ST R2: = COPY (STR1, POFSE 3, 2); Timdrow (TIM3, 39, 1); if ClockBell> -1 Then Begin IF (ClockBell <> 0) And (Pchar ('Timebell) " '), hinstance, SND_ASYNC OR SND_RESOURCE); // Clock's Whole Point "Bell" Voice Dec (ClockBell); End; IF (Pop3.Checked) and (STRTOTIME (DTIM) <= Time ()) THEN / / Judgment Whether it comes to timing begin form2.button2.caption: = 'cancel'; clockbell: = 120; form2.show; // Display to your own prompt. End; end;

Procedure TForm1.FormCreate (Sender: TOBJECT); // Reader started initialization setting VAR str1, str2: string; begintmFileName: = extractFilePath (Application.exename) 'clock1.ini'; timini: = tiniFile.create TMFileName); with timini doblegintextdef: = readstring ('content', 'text', "Enter you to your reminder"); dtim: = readstring ('parameter', 'time', '23: 59: 59 ' ); pop1.checked: = readbool ('parameter', 'reports Allow', TRUE); pop2.checked: = readbool ('parameter', 'second sound allowed "TRUE); pop3.checked: = readbool (' parameter ',' Timed Allow ', FALSE); Form1.Left: = Readinteger (' Location ',' X Coordinate ", 566); Form1.top: = Readinteger ('Location', 'Y Coordinate', 8); END; Timini.free; dtme: = time (); pop2.checked: = true; pop1.checked: = true; str1: = time (Time ()); str2: = COPY (STR1, 2, 1); if str2 = ':' Then Pofse: = 0 else pofse: = 1; Image1.canvas.brush.color: = CLBLACK ;; str2: = COPY (STR1, POFSE 6, 2); TIM3: = STRTOFLOAT (STR2); str2: = COPY (STR1, POFSE 3, 2); TIM2: = STRTOFLOAT (STR2); STR2: = COPY (STR1, 1, POFSE 1); TIM1: = STRTOFLOAT (STR2); ClockBell: = - 1; End; Procedure TFORM1.Image1Click (Sender: TOBJECT); // Dial Dial Mouse Click to process becompopUpMenu1.popup (Form1.Left 40, Form1.top 150);

Procedure tform1.pop1click (sender: TOBJECT); Beginif Pop1.checked the pop1.checked: = false else pop1.checked: = true; form1.tiniwr ();

Procedure tForm1.pop2click (sender: TOBJECT); beginif pop2.checked the pop2.checked: = false else pop2.checked: = true; form1.tiniwr ();

Procedure tform1.pop4click (sender: TOBJECT); beginform2.show; form1.tiniwr ();

Procedure TFORM1.POP5CLICK (Sender: TOBJECT); BeginClose;

procedure TForm1.pop3Click (Sender: TObject); beginif pop3.Checked thenbeginpop3.Checked: = false; form2.Button2.Caption: = 'Cancel'; end else begin pop3.Checked: = true; form2.Button2.Caption: = ' Close '; end; form1.tiniwr (); end; procedure TForm1.FormClose (Sender: TObject; var Action: TCloseAction); begintimini: = TIniFile.Create (' tmfilename '); with timini dobeginWriteinteger (' position ',' X Coordinate ', Form1.Left; // Save the initial X coordinate WriteInteger (' location ',' y coordinate ', form1.top); // save the initial Y coordinate end of the clock window; TIMINI.FREE;

END;

Procedure TFORM1.N1CLICK (Sender: Tobject); BeginshowMessage ('analog Alarm 0.1,' # 13 'Copy (R) IgHT by Suye.2001'; END;

End. After some of the above operations, one of our alarms has been completed, as long as you do some small changes, you will complete it, OK, talk about this, if you have any questions, welcome to me Home http://www.suye.8u8.com Ask, maybe you will get a good gain. Dream search, 2001.02.04

转载请注明原文地址:https://www.9cbs.com/read-5080.html

New Post(0)