GetSystemTime |
答題得分者是:st33chen
|
zhouying82
高階會員 發表:150 回覆:272 積分:189 註冊:2004-03-16 發送簡訊給我 |
|
st33chen
尊榮會員 發表:15 回覆:591 積分:1201 註冊:2005-09-30 發送簡訊給我 |
您好,
GetSystemTime API 函數的 宣告如下 : VOID GetSystemTime(LPSYSTEMTIME lpst) 是 VOID 型, 也就是沒有直接回傳值, 他是由 LPSYSTEMTIME 型的 lpst 指標回傳的 要取用的話是您例中的 st.year, st.hour, ... 等等 何不用 delphi 內建的 now ? if formatdatetime('hhnnss', datetimepicker1.time)=formatdatetime('hhnnss', now) 我想, 沒有用 formatdatetime 轉一下, 兩個時間(因為精確度的關係)要相等可能有點難. 參考一下
------
IS IT WHAT IT IS 我是 李慕白 請倒著唸. 又想把老話拿出來說, 請用台語發音 : 專家專家全是ROBOT CAR (滷肉腳啦); 都已接手這麼久了, 績效還是那麼爛, 講話還那麼大聲. |
zhouying82
高階會員 發表:150 回覆:272 積分:189 註冊:2004-03-16 發送簡訊給我 |
没有用啊,大大,还是不起作用,帮我看看,下面的代码是否有问题啊?
[code delphi] procedure TForm1.RadioButton2Click(Sender: TObject); var t:TdateTime; begin if radiobutton2.Checked then datetimepicker1.Enabled :=true; t:=datetimepicker1.Time ; end; procedure TForm1.Timer3Timer(Sender: TObject); begin timer3.enabled:=true; if formatdatetime('hhnn', t)=formatdatetime('hhnn', now) then text1:=labelededit2.Text ; text2:=labelededit3.Text ; cooltrayicon1.ShowBalloonHint(text1,text2,bitinfo,10); [/code]
------
断断续续的学了几年,还是一个初学者,永远支持Delphi !
編輯記錄
zhouying82 重新編輯於 2009-01-21 09:51:08, 註解 無‧
|
st33chen
尊榮會員 發表:15 回覆:591 積分:1201 註冊:2005-09-30 發送簡訊給我 |
您提供的程式不是很完整, 不能了解您要做什麼, 我嘗試猜一下您的問題所在, 請注意以下紅色部份(<-- 部份, 他沒變紅色)
===================引 用 zhouying82 文 章=================== 没有用啊,大大,还是不起作用,帮我看看,下面的代码是否有问题啊? [code delphi] procedure TForm1.RadioButton2Click(Sender: TObject); var t:TdateTime; begin if radiobutton2.Checked then <-- 有何用途, 且 then 若沒有 begin ... end 包起來, 只做其後一列. datetimepicker1.Enabled :=true; <-- 是否是 timer3.enabled := true; t:=datetimepicker1.Time ; end; procedure TForm1.Timer3Timer(Sender: TObject); begin timer3.enabled:=true; <-- 有何用途, 觸動以後再開? 如果原本 enabled 為 false, 永遠不會執行這一段. <-- 是否是 timer3.enabled := false; if formatdatetime('hhnn', t)=formatdatetime('hhnn', now) then <-- then 若沒有 begin ... end 包起來, 只做其後一列. text1:=labelededit2.Text ; text2:=labelededit3.Text ; cooltrayicon1.ShowBalloonHint(text1,text2,bitinfo,10); <-- 是否加 timer3.enabled := true; [/code]
------
IS IT WHAT IT IS 我是 李慕白 請倒著唸. 又想把老話拿出來說, 請用台語發音 : 專家專家全是ROBOT CAR (滷肉腳啦); 都已接手這麼久了, 績效還是那麼爛, 講話還那麼大聲.
編輯記錄
st33chen 重新編輯於 2009-01-21 10:32:31, 註解 無‧
|
zhouying82
高階會員 發表:150 回覆:272 積分:189 註冊:2004-03-16 發送簡訊給我 |
老大,好像还是不行吗?我重新设置了代码,您帮我看看呢?谢谢了。
[code delphi] unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls; type TForm1 = class(TForm) DateTimePicker1: TDateTimePicker; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin if formatdatetime('hhmmss',datetimepicker1.time)=formatdatetime('hhmmss', now) then showmessage('hello,world'); end; end. [/code]
------
断断续续的学了几年,还是一个初学者,永远支持Delphi ! |
st33chen
尊榮會員 發表:15 回覆:591 積分:1201 註冊:2005-09-30 發送簡訊給我 |
您好, 我這麼測, 可行, 參考一下 new project, 拉 label1, label2, timer1, datetimepicker1, button1 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls; type TForm1 = class(TForm) Button1: TButton; Timer1: TTimer; DateTimePicker1: TDateTimePicker; Label1: TLabel; Label2: TLabel; procedure Button1Click(Sender: TObject); procedure Timer1Timer(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin datetimepicker1.DateTime := now 1/24/60; // 一分鐘(就是 1/24/60)後 showmessage timer1.Enabled := true; end; procedure TForm1.Timer1Timer(Sender: TObject); begin LABEL1.Caption := FORMATDATETIME('HHNNSS', DATETIMEPICKER1.TIME); LABEL2.Caption := FORMATDATETIME('HHNNSS', NOW); if label1.Caption = label2.caption then begin timer1.enabled := false; showmessage('time up'); end; end; end.
------
IS IT WHAT IT IS 我是 李慕白 請倒著唸. 又想把老話拿出來說, 請用台語發音 : 專家專家全是ROBOT CAR (滷肉腳啦); 都已接手這麼久了, 績效還是那麼爛, 講話還那麼大聲. |
zhouying82
高階會員 發表:150 回覆:272 積分:189 註冊:2004-03-16 發送簡訊給我 |
|
jrsty
一般會員 發表:1 回覆:11 積分:7 註冊:2008-10-31 發送簡訊給我 |
個人小見解...
推st33chen大大用法~~~~ 下面人個人寫法@@ [code delphi] unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, ExtCtrls; type TForm1 = class(TForm) Button1: TButton; Edit1: TEdit; Timer1: TTimer; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; TimeStr: string; //用來存showmessage的時間 implementation {$R *.dfm} procedure TForm1.Timer1Timer(Sender: TObject); begin if(TimeStr=formatdatetime('hhmm',now()))then showmessage('hello.world'); //判斷時間=現在時日則showmessage 格式為hhmm end; procedure TForm1.Button1Click(Sender: TObject); begin TimeStr:=edit1.Text; //設定要顯示之時間 格式為 hhmm timer1.Interval:=10000; timer1.Enabled:=true; end; procedure TForm1.Button2Click(Sender: TObject); begin timer1.Enabled:=false; end; end. [/code] 小弟不才 初學程式....... 如果要判斷到秒~~ 那就把timer時間改短~~ 再把hhmm改為hhmmss 應該就可以~~~~ (應該吧@@) |
chenyk
高階會員 發表:14 回覆:95 積分:171 註冊:2002-07-08 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |