Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / December 2004

Tip: Looking for answers? Try searching our database.

Time of inactivity

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nicola - 29 Nov 2004 14:03 GMT
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
John M Deal - 29 Nov 2004 16:03 GMT
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

> 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
[quoted text clipped - 7 lines]
> Many thanks
> nq
Nicola - 29 Nov 2004 16:55 GMT
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

> 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
[quoted text clipped - 28 lines]
> > Many thanks
> > nq
Paul Wardle - 01 Dec 2004 19:23 GMT
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

> Thanks for Your answer Mr John
> My timer is in a separate module and I thought at Your solution.
[quoted text clipped - 41 lines]
>> > Many thanks
>> > nq
Nicola - 03 Dec 2004 01:49 GMT
GREAT !!!

This is the solution I was looking for...
I implemented a routine for the AddMessageFilter method:
It only stops and starts the timer every time a windows message (with msg
different from 275: the timer tick event) is processed in my application, in
order to reset the timer and restart its time.

I've only a little curiosity left:
What' s the difference between the timer.start method and the
timer.enabled=true instruction ??
It seems they start the timer in the same way resetting its time... so seems
there's no way to stop and restart the timer without reset the time
elapsed...
Is it right ???

Many thanks
bye
nq

> Look at the Application.AddMessageFilter method.
>
[quoted text clipped - 53 lines]
> >> > Many thanks
> >> > nq

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.