Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How To Logoff My App

Posted on 2008-06-12
10
Medium Priority
?
158 Views
Last Modified: 2010-04-30
for Windows Application with vb 2005 , if the user doesn't do any thing with a while say 5 minuets , I want the system to automatically log off.  
0
Comment
Question by:Ahmadal_najjar2003
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
10 Comments
 
LVL 10

Expert Comment

by:cool12399
ID: 21781173
* Have 1 global integer variable
* Have a timer that increments this global variable each second by 1
* if the value is higher than 5*60 (ie 300 = 5 minutes), then close application
* For any mouse/keyboard event that is triggered in the application, reset the global variable to 0
0
 

Author Comment

by:Ahmadal_najjar2003
ID: 21786202
Ok , How to follow the mouse and keyboard events within the whole application
0
 

Author Comment

by:Ahmadal_najjar2003
ID: 21814625
Ok , How to follow the mouse and keyboard events within the whole application
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 70

Expert Comment

by:Éric Moreau
ID: 21814907
A long time ago (in an old VB6 application) I was having an invisible form with a timer which every half minute was checking for the active form, the active control on that form and the value of that control when possible. If none of those values were modified for 5 minutes (I was checking every 30 seconds) then I was leaving the application. Maybe you can do something like this.
0
 

Author Comment

by:Ahmadal_najjar2003
ID: 21815391
It is really a nice Idea , but in some cases give this message
"Object reference not set to an instance of an object"

While My Code Like this

If MyMousePosition = Control.MousePosition And _
           MyActiveForm = ActiveForm.Name And MyActiveControl = ActiveForm.ActiveControl.Name Then

do you have any Idea, Why.
0
 

Author Comment

by:Ahmadal_najjar2003
ID: 21815454
After I watch the Error , it belongs to ActiveForm.name , I feel this happen while I am closing the active form.

Any Suggest
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 2000 total points
ID: 21815626
You can trap it something like this:

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Static sstrPreviousForm As String = String.Empty
        Static sstrPreviousControl As String = String.Empty
        Static sdtmLastAction As DateTime

        Dim strCurrentForm As String
        Dim strCurrentControl As String
        Try
            strCurrentForm = ActiveForm.Name
        Catch ex As Exception
            strCurrentForm = String.Empty
        End Try

        Try
            strCurrentControl = ActiveForm.ActiveControl.Name
        Catch ex As Exception
            strCurrentControl = String.Empty
        End Try

        If (strCurrentForm <> sstrPreviousForm) OrElse (strCurrentControl <> sstrPreviousControl) Then
            sstrPreviousForm = strCurrentForm
            sstrPreviousControl = strCurrentControl
            sdtmLastAction = Date.Now
            Label1.Text = sstrPreviousForm
            Label2.Text = sstrPreviousControl
        End If
        Label3.Text = DateDiff(DateInterval.Minute, sdtmLastAction, Date.Now).ToString ' Date.Now.ToLongTimeString

        If DateDiff(DateInterval.Minute, sdtmLastAction, Date.Now) > 5 Then Application.Exit()
    End Sub
0
 

Author Comment

by:Ahmadal_najjar2003
ID: 21816041
Thats Very Nice .

Thank You Very Much. But I need from you one thing if you can. You Use static inside the timer
is this mean just for the first time when fired just assign string.empty value . then after that will keep the value which which assign later. If you can help me for the lifetime and visibilty of this .

0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 21816118
Static variables have the lifetime of the class (form) in which it is found but they are only visible from within the method.
0
 

Author Closing Comment

by:Ahmadal_najjar2003
ID: 31466784
Thank You a lot
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question