|
-
February 8th, 2000, 03:21 PM
#1
Getting window that has the focus
Is there an API function that will return the window handle of the window that currently has the focus on the desktop ?
-
February 8th, 2000, 04:08 PM
#2
Re: Getting window that has the focus
Sure, it's GetForeGroundWindow(), example:
private Declare Function GetForegroundWindow Lib "user32" () as Long
private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (byval hwnd as Long, byval lpString as string, byval cch as Long) as Long
private Sub Form_Load()
Timer1.Interval = 100
End Sub
private Sub Timer1_Timer()
static lHwnd as Long
Dim lCurHwnd as Long
Dim sText as string * 255
lCurHwnd = GetForegroundWindow
If lCurHwnd = lHwnd then Exit Sub
lHwnd = lCurHwnd
If lHwnd <> hwnd then
Caption = "ActiveWidow: " & Left$(sText, GetWindowText(lHwnd, byval sText, 255))
else
Caption = "ActiveWindow: Form1"
End If
End Sub
Aaron Young
Analyst Programmer
[email protected]
[email protected]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|