pr_wainwright
asked on
Simple HH:MM:SS counter
How can I write a simple HH:MM:SS counter to time a procedures duration ?. The counter does not have to be very accurate just a start/stop counter to the nearest second or so. I would like a coded answer without using any components.
Thanks
Paul.
Thanks
Paul.
ASKER
DeNavigator,
Sorry, maybe my question was not very clear. I was hoping for say a TLabel caption to update in real time as the procedure executed e.g. '00:00:01' - '00:00:02'... etc.
Thanks
Paul.
Sorry, maybe my question was not very clear. I was hoping for say a TLabel caption to update in real time as the procedure executed e.g. '00:00:01' - '00:00:02'... etc.
Thanks
Paul.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
PS - if you are doing a processor-intensive procedure, you may want to call Application.ProcessMessage s every now and again (at *least* once per second) to allow the timer to trigger.
Geoff M.
Geoff M.
I created once a timer-component. If you like the code just post a comment with your email and i'll send you the sources. if you understan dutch you could have a look at this: http://www.nldelphi.com/cgi-bin/articles.exe/ShowArticle?ID=10257
I wrote this article and is describes the stopwatch component. (in dutch :) )
I wrote this article and is describes the stopwatch component. (in dutch :) )
ASKER
Geoff,
Your code is exactly what I required. Simple & works perfectly.
Thanks
Paul.
P.S. Thanks also to DeNavigator.
Your code is exactly what I required. Simple & works perfectly.
Thanks
Paul.
P.S. Thanks also to DeNavigator.
var
TotalTime, StartTime: Cardinal;
begin
StartTime := GetTickCount;
// Here your code
TotalTime := GetTickCount - StartTime;
ShowMessage('It took ' + IntToStr(TotalTime) + ' msec.');
end;