954,157 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

to show timeleft to next picture

Ive made a Security Screensaver whit the options to show random pictures. and it show the start time, time went and then im trying to get it to show time left by minus lasttime whit currenttime

It just doesnt work,
if anyone could help me i would very much appreciate it this is how the code looks:

procedure TForm7.TimerSecTimer(Sender: TObject);
var item : tlistitem; N : integer; randomnr : integer; x : integer; startime : tdatetime; timeleft : tdatetime; lasttime : tdatetime; currenttime : tdatetime;
begin
if i = Listview1.Items.Count -1 then
begin
if checkbox1.Checked = true then
begin
i := 0;
item := listview1.Items[i];
form2.image1.Picture.LoadFromFile(item.Caption);
end
else
begin
timersec.Enabled := false;
end;
end
else
begin
if checkbox2.Checked = true then
begin

if checkbox5.Checked = false then timersec.Enabled := false;

form2.Label9.Caption := 'Start time:' + timetostr(now); {here i show the start time}
startime := now; {saves the starttime}

randomnr := random(listview1.Items.Count -1);

form2.ProgressBar1.Max := listview1.Items.Count;

for n:=1 to ListView1.Items.Count do
begin
application.ProcessMessages;

if form2.checkbox1.checked = true then break;


form2.ProgressBar1.Position := form2.ProgressBar1.Position + 1;

form2.LblList1.Caption := 'Lisview1 : ' + inttostr(form2.ProgressBar1.Position) + ' out of ' + inttostr(form2.ProgressBar1.Max);

SetWindowPos(form3.Handle, HWND_TOPMOST, 0,0,0,0, SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE);

if checkbox3.Checked = true then
begin


x := 0;
form2.ProgressBar2.Max := listview2.Items.Count;
While x

darkyere
Newbie Poster
17 posts since Nov 2008
Reputation Points: 10
Solved Threads: 0
 

Firstly without code tags thats kinda hard to read
Secondly, you dont mention in what way your time remaining hasnt worked.

LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
 

I would use my time on making the question more understandable if not ive found the answer elsewhere...

here it is.

I think you should declare starttime and lasttime outside of your procedure TimerSecTimer. You will always access to the same two memory spots, which I'm afraid isn't the case when you declare these variables inside TimerSecTimer. This procedure is sort of closed when it's finished, and another is opened next time OnTimer event is fired.

Best regards,
Darkyere

darkyere
Newbie Poster
17 posts since Nov 2008
Reputation Points: 10
Solved Threads: 0
 

Then mark the thread as solved.

However, a better statement of the problem would have helped too.

LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You