Re: auto timeout for winform application

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Cor Ligthert (notmyfirstname_at_planet.nl)
Date: 10/10/04


Date: Sun, 10 Oct 2004 12:29:32 +0200

Dayne,

Assuming it is a windowform, than I think that you can use something as this
beneath when it is a webform you can do as Terry told, in is almost the same
way as this. And please stay as Herfried told as well next time in the
original question thread.

\\\Need a webform and some controls however a button and a textbox as
minimum
Private WithEvents mytimer As New Windows.Forms.Timer
Private Sub Form1_Load(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load
        doSet(Me)
    End Sub
    Private Sub doSet(ByVal parentCtr As Control)
        Dim ctr As Control
        For Each ctr In parentCtr.Controls
            AddHandler ctr.Click, AddressOf eventfired1
            AddHandler ctr.Enter, AddressOf eventfired1
            AddHandler ctr.KeyDown, AddressOf eventfired2
            doSet(ctr)
        Next
    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles mytimer.Tick
        Me.Close()
    End Sub
    Private Sub eventfired1(ByVal sender As System.Object, _
    ByVal e As System.EventArgs)
        eventfired()
    End Sub
    Private Sub eventfired2(ByVal sender As System.Object, _
       ByVal e As Windows.forms.KeyEventArgs)
        eventfired()
    End Sub
    Private Sub eventfired()
        mytimer.Enabled = True
        mytimer.Stop()
        mytimer.Interval = 3000
        mytimer.Start()
    End Sub
///

I hope this helps a little bit?

Cor


Quantcast