Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Minimize a form after a period of user inactivity

Status
Not open for further replies.

ErroR

Technical User
Apr 9, 2001
79
US
Any suggestions for an efficient method to have my application minimize itself when a period of time elapses and the user has no interaction with the form? It also must cancel the minimize if the user clicks on something else before the timeout.

For instance, user uses my application to launch something another program. They work in the newly spawned application, and my app needs to stay running, minimize, and be ready without re-launching it.

Currently, it's on a timer that is enabled once my tool is used. But if the user made a mistake, and tries to use it again, it will minimize while they try to use it. I thought about disabling the timer via the KeyDown or MouseDown events. Would that be a lot of overhead for the app to process each and every keystroke and mouse click, just to satisy this piece of it?
 
I have done this via a function. Here is the function I use to maximize, minimize windows etc. Hope this helps..

'Minimize Any Window
'In Declarations of Module

Declare Function ShowWindow Lib "User32" (ByVal Hwnd As
Long, ByVal nCmdShow As Long) As Long
Public Const SW_SHOWMINIMIZED = 2
'In Module Put...


Sub MiniWindow(Hwnd)
'minimizes the "hWnd" window
mi = ShowWindow(Hwnd, SW_MINIMIZE)
End Sub
'Maximize Any Window
'In Declarations of Module Put...


Declare Function ShowWindow Lib "User32" (ByVal Hwnd As
Long, ByVal nCmdShow As Long) As Long
Public Const SW_SHOWMAXIMIZED = 3
'In Module Put...


Sub MaxiWindow(Hwnd)
'maximizes the "hWnd" window
mi = ShowWindow(Hwnd, SW_MAXIMIZE)
End Sub
'Close Any Window
'In Declarations of Module Put...


Declare Function SendMessageByNum& Lib "User32" Alias
"SendMessageA" (ByVal Hwnd As Long, ByVal wMsg As Long,
ByVal wParam As Long, ByVal lParam As Long)
Public Const WM_CLOSE = &H10
'In Module Put...


Sub CloseWindow(Hwnd)
'Closes the "hWnd" window
mi = SendMessageByNum(Hwnd,WM_CLOSE,0,0)
End Sub
 
Well.. I'm just using Me.Windowstate to control the minimize.

My question is, does anyone know a way to intiate and/or cancel the minimize timer that is better than putting a Timer.Enabled = False in the KeyDown and MouseDown events on the form?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top