|
How
can I find out whether my VB-application has the
focus?
Open a new form and add an timer and an label to
it.
Set the timer's interval to 200 (Your application will
look
5 times a second if it has got the focus)
Then use the following code in your form:
Option Explicit
Private Declare Function GetActiveWindow Lib
"user32" () As Long
Private Sub Timer1_Timer()
If GetActiveWindow <> 0 Then
Label1.Caption = "I have the focus" 'if
GetActiveWindow is non-zero
Else
Label1.Caption = "Another program has the
focus" 'if GetActiveWindow is zero
End If
End Sub
Tip submitted by Uwe Will
|
|
|
|