[didn't see the original post or half the responses so i don't know if this
has been mentioned yet]

I used a TTimer

Set the TTimer interval to say 5000 msecs, and have a variable on the
form/datamodule to count how many seconds have passed.
...
    IdleSecondsCount : integer;
...

procedure Timer1Timer(Sender :TObject);
begin
  inc(IdleSecondsCount, 5);
  if IdleSecondsCount >= 60*5 then
  begin
    <Put your code to close the application or whatever here>
  end;
end;

Then add an event for Application.OnMessage (you could also do this using a
WindowProc override I guess) and use THintWindow.isHintMsg (or copy the code
from it)

procedure TMainForm.AppMessage(var Message: TMsg; var handled : Boolean);
begin
  if FHintWindow.isHintMsg(Message) then
  begin
    IdleSecondsCount := 0;

    { I also disable my giant hint boxes at this point ... }
    if Assigned(BigHintBoxForm) then
      if BigHintBoxForm.Visible then
        BigHintBoxForm.Visible := false;
  end;
end;

isHintMsg just looks like

function THintWindow.IsHintMsg(var Msg: TMsg): Boolean;
begin
  with Msg do
    Result := ((Message >= WM_KEYFIRST) and (Message <= WM_KEYLAST)) or
      ((Message = CM_ACTIVATE) or (Message = CM_DEACTIVATE)) or
      (Message = CM_APPKEYDOWN) or (Message = CM_APPSYSCOMMAND) or
      (Message = WM_COMMAND) or ((Message > WM_MOUSEMOVE) and
      (Message <= WM_MOUSELAST)) or (Message = WM_NCMOUSEMOVE);
end;


No worries matey



> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of Patrick Dunford
> Sent: Wednesday, 27 September 2000 1:46
> To: Multiple recipients of list delphi
> Subject: RE: [DUG]: Application Idle
>
>
> Application.OnIdle is not the same. It fires when the app becomes
> idle. But
> it does not tell you how long the app has been idle.
>
> However you may be able to implement a timer by polling with
> WaitForInputIdle. Application.OnIdle event is equivalent to calling
> WaitForInputIdle with the parameter value INFINITE.
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> > Behalf Of Rohit Gupta
> > Sent: Wednesday, 27 September 2000 13:12
> > To: Multiple recipients of list delphi
> > Subject: Re: [DUG]: Application Idle
> >
> >
> > IF you havent found it yet... try teh application.onidle event
> >
> > To:                 Multiple recipients of list delphi
> > <[EMAIL PROTECTED]>
> > Send reply to:      [EMAIL PROTECTED]
> > From:               "Dedy Darmayanto" <[EMAIL PROTECTED]>
> > Subject:            [DUG]:  Application Idle
> > Date sent:          Mon, 25 Sep 2000 16:05:46 +0700
> >
> > > Hi,
> > >
> > > How to detect Application Idle in Delphi,
> > > I mean that when the user does not use application in 5 minutes,
> > > then the application close
> > >
> > > Dedy,
> > >
> > >
> >
> >
> >
> > Rohit
> >
> > ======================================================================
> > CFL - Computer Fanatics Ltd.  21 Barry's Point Road, AKL, New Zealand
> > PH    (649) 489-2280
> > FX    (649) 489-2290
> > email [EMAIL PROTECTED]  or  [EMAIL PROTECTED]
> > ======================================================================
> >
> > ------------------------------------------------------------------
> > ---------
> >     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"
> >
>
> ------------------------------------------------------------------
> ---------
>     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"

---------------------------------------------------------------------------
    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