snakedjip
February 8th, 2000, 02:21 PM
Is there an API function that will return the window handle of the window that currently has the focus on the desktop ?
|
Click to See Complete Forum and Search --> : Getting window that has the focus snakedjip February 8th, 2000, 02:21 PM Is there an API function that will return the window handle of the window that currently has the focus on the desktop ? snakedjip February 8th, 2000, 02:21 PM Is there an API function that will return the window handle of the window that currently has the focus on the desktop ? snakedjip February 8th, 2000, 02:21 PM Is there an API function that will return the window handle of the window that currently has the focus on the desktop ? Aaron Young February 8th, 2000, 03:08 PM 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 ajyoung@pressenter.com aarony@redwingsoftware.com codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |