菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
165
0

Delphi Delay 延时计数的功能。 下面的方法都是思路,但是没有用在项目上

原创
05/13 14:22
阅读数 28363

procedure Tfrm_InstrumentControl.aa;
var
CurLength: Word;
vTimeLength: Word;
begin
Screen.Cursor := crHourGlass;
try
vTimeLength := StrToIntDef(num_GrossAnalyzeTime.Text, 0) * 60;
CurLength := 0;
while CurLength < vTimeLength do
begin
if IsCanExcute(1000) then
begin
iSevenSegmentClock1.Seconds := CurLength;
Application.ProcessMessages;
end;
CurLength := CurLength + 1;
end;

finally
Screen.Cursor := crDefault;
end;
end;


procedure Tfrm_InstrumentControl.Delay111(msecs:integer);
var
Tick: DWord;
Event: THandle;
curTick: DWord;
begin
Event := CreateEvent(nil, False, False, nil);
try
Tick := GetTickcount + DWord(msecs);;
curTick := 0;
while (msecs > 0) and (MsgWaitForMultipleObjects(1, Event, False, msecs, QS_ALLINPUT) <> WAIT_TIMEOUT) do
begin
if (curTick mod 1000) = 0 then
begin
//iSevenSegmentClock1.Seconds := Trunc(curTick/1000);
// iSevenSegmentClock1.Hours := Trunc(curTick/(1000*60*24));
// iSevenSegmentClock1.Minutes := Trunc(curTick/(1000*60));
// iSevenSegmentClock1.Seconds := Trunc(curTick/(1000));
// iSevenSegmentClock1.SetTimeNoEvent(curTick);
iSevenSegmentClockSMPTE1.Time := curTick/(1000*60*60*24);
Application.ProcessMessages;
end;
inc(curTick);
msecs := Tick - GetTickcount;
end;
finally
CloseHandle(Event);
end;
end;


procedure Tfrm_InstrumentControl.Delay2(MaxWaitTime: Cardinal);
var
WaitedTime:Cardinal;
begin WaitedTime:=0; // while (WaitedTime<MaxWaitTime) do
// begin
// SleepEx(100,False);
// Inc(WaitedTime,1000);
// if (WaitedTime mod 1000) = 0 then
// iSevenSegmentClock1.Seconds := WaitedTime/1000;
// Application.ProcessMessages ;
// end;
end;

发表评论

0/200
165 点赞
0 评论
收藏