關於 timer 與聲效問題 |
答題得分者是:borland_delphi70
|
francolau
一般會員 發表:4 回覆:4 積分:1 註冊:2006-11-21 發送簡訊給我 |
我想做一個倒數計時, 在倒數到零時發出聲, 但當倒數至 '1' 秒時便會先停留在 '1' 秒, 發出聲響後才數至 '0', 請問如何解決? 是否要將發聲的指令放在別的地方??
procedure TForm1.Timer1Timer(Sender: TObject); begin timer1.Tag:=timer1.Tag - 1; if timer1.Tag > 0 then label1.Caption :=inttostr(timer1.Tag); if timer1.tag = 0 then begin timer1.Enabled:=False; label1.Caption:= inttostr(timer1.tag); Label1.Font.Color:=clBlack; Windows.Beep(500, 3000); end; end; |
P.D.
版主 發表:603 回覆:4038 積分:3874 註冊:2006-10-31 發送簡訊給我 |
你都把程式寫出來了, 不知自己run過沒有?
另外, 你希望在"1"秒作動, if timer1.tag=1 才對, 因為=1後作動, 然後歸零, 如果=0 是否等於count to 0 才作動 ===================引 用 francolau 文 章=================== 我想做一個倒數計時, 在倒數到零時發出聲, 但當倒數至 '1' 秒時便會先停留在 '1' 秒, 發出聲響後才數至 '0', 請問如何解決? 是否要將發聲的指令放在別的地方?? procedure TForm1.Timer1Timer(Sender: TObject); begin timer1.Tag:=timer1.Tag - 1; if timer1.Tag > 0 then label1.Caption :=inttostr(timer1.Tag); if timer1.tag = 0 then begin timer1.Enabled:=False; label1.Caption:= inttostr(timer1.tag); Label1.Font.Color:=clBlack; Windows.Beep(500, 3000); end; end; |
francolau
一般會員 發表:4 回覆:4 積分:1 註冊:2006-11-21 發送簡訊給我 |
|
borland_delphi70
中階會員 發表:8 回覆:50 積分:51 註冊:2002-12-06 發送簡訊給我 |
===================引 用 francolau 文 章=================== 我想做一個倒數計時, 在倒數到零時發出聲, 但當倒數至 '1' 秒時便會先停留在 '1' 秒, 發出聲響後才數至 '0', 請問如何解決? 是否要將發聲的指令放在別的地方?? procedure TForm1.Timer1Timer(Sender: TObject); begin timer1.Tag:=timer1.Tag - 1; if timer1.Tag > 0 then label1.Caption :=inttostr(timer1.Tag); if timer1.tag = 0 then begin timer1.Enabled:=False; label1.Caption:= inttostr(timer1.tag); Label1.Font.Color:=clBlack; Windows.Beep(500, 3000); end; end; ===================引 用 francolau 文 章=================== 這只是 GUI 上的 Delay 請Beep前加入 Label1.Refresh; procedure TForm1.Timer1Timer(Sender: TObject); begin timer1.Tag:=timer1.Tag - 1; if timer1.Tag > 0 then label1.Caption :=inttostr(timer1.Tag); if timer1.tag = 0 then begin timer1.Enabled:=False; label1.Caption:= inttostr(timer1.tag); Label1.Font.Color:=clBlack; Label1.Refresh; Windows.Beep(500, 3000); end; end;
編輯記錄
borland_delphi70 重新編輯於 2012-08-22 00:33:28, 註解 無‧
|
francolau
一般會員 發表:4 回覆:4 積分:1 註冊:2006-11-21 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |