Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How To Logoff My App

Posted on 2008-06-12
10
Medium Priority
?
159 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
  • 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

916 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