GetActiveWindow Function

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

Platforms: Win 32s, Win 95/98, Win NT

GetActiveWindow returns a handle to your program's currently active window. This only works with windows created by your application -- in other words, it won't find the active window of other programs. If your program is in the background, the function will get the window that would be active if the program were active. If an error occurs, or if there is no active window to your program, the function instead returns 0.

Example:

' Use FlashWindow to flash the title bar of the program's
' currently active window once.
Dim hactive As Long  ' handle to the active window
Dim retval As Long  ' return value

hactive = GetActiveWindow()  ' get the handle of the program's active window
' The next three lines flash the window's title bar
retval = FlashWindow(hactive, 1): Sleep 250
retval = FlashWindow(hactive, 1): Sleep 250
retval = FlashWindow(hactive, 0)

See Also: GetForegroundWindow, GetWindow, SetActiveWindow
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/getactivewindow.html