Index of reff


Declare Function GetForegroundWindow Lib "user32.dll" () As Long

Platforms: Win 95/98, Win NT

GetForegroundWindow finds which window is currently the foreground window. The foreground window is the window, usually at the top of the Z-order, with which the user is currently working with -- i.e., the window with the focus. The function returns 0 if an error occured, or the handle of the foreground window if successful.

Example:

' Display the title bar text of the foreground window. Dim hforewnd As Long  ' receives handle of foreground window Dim slength As Long  ' length of foreground window's title bar text Dim wintext As String  ' buffer for foreground window's title bar text Dim retval As Long  ' return value hforewnd = GetForegroundWindow()  ' determine the foreground window slength = GetWindowTextLength(hforewnd) + 1  ' length of its title bar text wintext = Space(slength)  ' make room in the buffer to receive the text retval = GetWindowText(hforewnd, wintext, slength)  ' get title bar text wintext = Left(wintext, slength - 1)  ' remove null character from end of string Debug.Print "The window "; wintext; " is the foreground window."

See Also: SetForegroundWindow
Category: Windows

Go back to the alphabetical Function listing.
Go back to the Reference section index.


This page is copyright © 2000 Paul Kuliniewicz. Copyright Information.
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/g/getforegroundwindow.html



Windows API Guide
Windows API Guide - Reference - Volume 1: Version 3.0 For the MS-DOS and PC-DOS Operating Systems
ISBN: B001V0KQIY
EAN: N/A
Year: 1998
Pages: 610

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net