Re: Time of inactivity

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Paul Wardle (p.wardle_at_ntlworld.com)
Date: 12/01/04


Date: Wed, 1 Dec 2004 19:23:28 -0000

Look at the Application.AddMessageFilter method.

You can put in a hook at the application level. Look for mouse and keyboard
messages - make note of the time that you last saw one of these messages.

When your timer fires, check the time since you last saw a keyboard or mouse
message and then prompt if the TimeSpan is over 5 minutes.

Let me know if you need any further help.

Paul

"Nicola" <Nicola@discussions.microsoft.com> wrote in message
news:1EACC70C-A240-4A48-B52B-9D9A43FDE68A@microsoft.com...
> Thanks for Your answer Mr John
> My timer is in a separate module and I thought at Your solution.
> It'll surely work fine, but I hoped there was a different way, as a
> general
> event to put in the application, to avoid to monitor the mouse event and
> the
> key event for every form... I know I can do it with a general routine
> instantiated with the addhandler, addressof method...
>
> Many thanks for Your help...
> Bye
> nq
>
> "John M Deal" wrote:
>
>> Seems like there are a number of variables involved here that you didn't
>> specify so I'm going to approach this as if you only had a single form
>> that was only monitoring itself (as opposed to your whole system).
>>
>> It seems to me that you should probably put the timer into its own class
>> (separate from the forms of the application). That class should also
>> provide event handlers for the keyboard and mouse events for the form in
>> your application. When the form is instantiated I'd link up the event
>> handlers to the events in the form. The form instantiation code should
>> also start up the timer. Now anytime one of the event handlers fires
>> off, I'd reset the timer. Also be sure to turn the KeyPreview property
>> for the form on.
>>
>> This concept should be able to be expanded to larger application. Hope
>> it helps.
>>
>> Have A Better One!
>>
>> John M Deal, MCP
>> Necessity Software
>>
>> Nicola wrote:
>> > I have a vb.net application that starts with a login form.
>> > I would like to show it again after 5 minutes of inactivity of the
>> > application.
>> >
>> > Now, I use a timer and I start it in the application.idle event, but it
>> > doesn't work fine, because it shows the login form every 5 minutes of
>> > activity or inactivity of the application, without differences...
>> >
>> > How can I solve it ????
>> > Many thanks
>> > nq
>> >
>>



Relevant Pages

  • Re: Time of inactivity
    ... My timer is in a separate module and I thought at Your solution. ... The form instantiation code should ... Now anytime one of the event handlers fires ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Painless micro program
    ... What problem did you have with the timer? ... screamer either (12 clocks per op, ... But I've used a 6502 to make a keyboard scanner with N-key rollover - I ... found its architecture very pleasant to work with, ...
    (sci.electronics.design)
  • Re: Events and Asynchronous processing
    ... Public Event OnData(ByVal mt As MessageTypeEnum, ByVal src SourceEnum, _ ... How may I pass event arguments to the event handlers, ... Well, if there's only one timer and it has to handle multiple events, there ... needs to be a way to tell which path to take, depending on the state flag.. ...
    (microsoft.public.vb.com)
  • Re: Application Timeout Required
    ... Considering the Keyboard and mouse, with a full-blown Mdi app, it would be a ... > You could attach to the Application.Idle event, check the active control ... Set the timer to fire every 20 minutes and reset it when the ... > Another idea would be track when the user uses the keyboard (use the ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Time of inactivity
    ... It seems to me that you should probably put the timer into its own class ... Now anytime one of the event handlers fires ... > I have a vb.net application that starts with a login form. ... > activity or inactivity of the application, ...
    (microsoft.public.dotnet.framework.windowsforms)