,
' API
'
Private Declare Function GetForegroundWindow Lib user32
() As Long
Private Declare Function GetWindowThreadProcessId Lib
user32 _
(ByVal hwnd As Long, lpdwProcessId As Long) As Long
' ,
' ,
'
Function IsActiveApp(frm As Form) As Boolean
Dim RunningAppProcessID As Long
Dim CurrentProcessID As Long
' ProcessID VB
GetWindowThreadProcessId frm.hwnd, RunningAppProcessID
' ProcessID
GetWindowThreadProcessId GetForegroundWindow(), CurrentProcessID
' True ID
IsActiveApp = (RunningAppProcessID =
CurrentProcessID)
End Function
'
'
Private Sub Timer1_Timer()
If IsActiveApp(Me) Then
Me.Caption = Time & & App.Title &
is Active
Else
Me.Caption = Time & & App.Title &
is Inactive
End If
End Sub
|