線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1740
推到 Plurk!
推到 Facebook!

關於 timer 與聲效問題

答題得分者是:borland_delphi70
francolau
一般會員


發表:4
回覆:4
積分:1
註冊:2006-11-21

發送簡訊給我
#1 引用回覆 回覆 發表時間:2012-08-17 21:38:09 IP:113.52.xxx.xxx 訂閱
我想做一個倒數計時, 在倒數到零時發出聲, 但當倒數至 '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

發送簡訊給我
#2 引用回覆 回覆 發表時間:2012-08-18 01:45:58 IP:118.160.xxx.xxx 未訂閱
你都把程式寫出來了, 不知自己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

發送簡訊給我
#3 引用回覆 回覆 發表時間:2012-08-21 12:59:35 IP:113.52.xxx.xxx 訂閱
我是希望倒數到'0' 才發聲.
但當倒數到'1' 就會停下, 發聲, 然後才到'0'.
borland_delphi70
中階會員


發表:8
回覆:50
積分:51
註冊:2002-12-06

發送簡訊給我
#4 引用回覆 回覆 發表時間:2012-08-22 14:32:47 IP:118.163.xxx.xxx 訂閱

===================引 用 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

發送簡訊給我
#5 引用回覆 回覆 發表時間:2012-08-22 23:34:49 IP:113.52.xxx.xxx 訂閱
問題解決了,謝謝!
編輯記錄
francolau 重新編輯於 2012-08-22 09:46:00, 註解 無‧
系統時間:2024-03-29 22:23:48
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!