OK, this should now detect when the screen saver is on and when it turns off, and then 
off - on =
total, and add that number to a listbox (TL4). So someone tell me why this code 
doesn't work?

Thanks, Gajo

------------------------
switch: boolean = false;     { this procedure is done by a Timer, so I need to use a 
switch that
would tell when sson or ssoff has changed, and not let the Timer change it again }
....

procedure TForm1.Timer1Timer(Sender: TObject);
var
  sson, ssoff, sstotti: TDateTime;
begin

if switch = false then begin
 if SystemParametersInfo(SPI_SETSCREENSAVEACTIVE,1,nil,0) <> false then begin    // ss 
has activated

  sson := Now;
  switch := True;
  end;
 end else

if switch = true then begin
if SystemParametersInfo(SPI_SETSCREENSAVEACTIVE,0,nil,0) <> false then begin
 ssoff := Now;
 switch := False;
 sstotti := ssoff - sson;
 TL4.Items[index] := TimeToStr(sstotti);
 end;
end;

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to