Window app timeout implementation

  • Thread starter Thread starter feng
  • Start date Start date
F

feng

In our VB.Net Windows application we need to implement
a "timeout" type of funtionality - If the the user leave
the application idle for certain peroid of time, depending
on configureable setting, then I want the system to
timeout and send him/her to login again.

To do this all I need is a client side timer that controls
the timeout. The difficaulty for me is how to implement
the re-setting of the timer. Because any user action in
the application's UI, such as a mouse clicking, a key
strok, sould reset the timer. But how do I capture all
those events? It's almost like that I need a "catch-all"
type of top level event that captures all event. But how
do I do that?

Thanks!
 
You'll need to add a message filter to the Application class, this will
PreProcess all windows messages

public class MessageFilter
implements IMessageFilter

public function PreFilterMessage(m as Message) as Boolean
' Pre process message
' Return False and windows will process the message in the normal
way
' or True to not process the message
end function
end class

This will be you "catch-all" top level event

Hope this helps
Neil
 
Thanks for you help!

For some reason I can't make it work. I know that I am
doing something stupid, but I just can't figure out what.

My application is a windows form. So what I do is that I
have my form implement IMessageFilter interface and hoping
that any user events, like mouse click and key strok, will
invoke the function PreFilterMessage. Unfortunityly, this
doesn't happen to me -- the function never get invoked.

Do you see what I am doing wrong here?

Thanks again!
 
Back
Top