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)
Related Calls: GetForegroundWindow, GetWindow, SetActiveWindow
Category: Windows
Back to the index.