Private Declare Function GetForegroundWindow Lib "user32" () As Long Private Sub Timer1_Timer() If GetForegroundWindow <> 句柄 Then Me.Caption = "失去焦点" Else Me.Caption = "得到焦点" End If End Sub