GetActiveWin




Private Declare Function SetActiveWindow Lib "User32" _
(ByVal hwnd As Long) As Long
Private Declare Function GetActiveWindow Lib "User32" _
() As Integer
Dim MyHandleOnThings As Integer

Private Sub Command1_Click()
Timer1.Enabled = True
MyHandleOnThings = GetActiveWindow
Text3.Text = MyHandleOnThings
End Sub

Private Sub Command2_Click()
Timer1.Enabled = False
End Sub

Sub Timer1_Timer()
'Compare the handle of the currently

'active Window with the handle of the Form1 window:

Text1.Text = Form1.hwnd
Text2.Text = GetActiveWindow()
If GetActiveWindow() <> MyHandleOnThings Then
'Do form's lost-focus routines here.

SetActiveWindow (MyHandleOnThings)
End If
End Sub











( getactivewin.html )- by Paolo Puglisi - Modifica del 17/12/2023