Results 1 to 5 of 5

Thread: [RESOLVED] [2005] Use timer control to end application

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2007
    Posts
    362

    Resolved [RESOLVED] [2005] Use timer control to end application

    I want to exit my application if there has been no activity on the PC for 10 mins. How can i use the timer control to do this ?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2005] Use timer control to end application

    I don't know a simple answer to your question but I wanted to point out that Timers are not controls. If it doesn't inherit the Control class then it's not a control.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: [2005] Use timer control to end application

    you can use an API call in your timer_tick event

    vb Code:
    1. Imports System.Runtime.InteropServices
    2.  
    3. Public Class Form1
    4.  
    5.     Private Declare Function GetLastInputInfo Lib "user32.dll" _
    6.         (ByRef plii As PLASTINPUTINFO) As Boolean
    7.  
    8.     Private Structure PLASTINPUTINFO
    9.         Dim cbSize As Integer
    10.         Dim dwTime As Integer
    11.     End Structure
    12.  
    13.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    14.         Dim oPLII As PLASTINPUTINFO
    15.  
    16.         oPLII.cbSize = Marshal.sizeof(oPLII)
    17.  
    18.         GetLastInputInfo(oPLII)
    19.         TextBox1.Text = CType((Environment.TickCount - oPLII.dwTime) / 1000, String)
    20.  
    21.     End Sub
    22.  
    23. End Class

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2007
    Posts
    362

    Re: [2005] Use timer control to end application

    It says Marshal is not declared. What should i do ?
    Also where do i set the ending time ?

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2007
    Posts
    362

    Re: [2005] Use timer control to end application

    I figured it out... Thanks Paul !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width