GetTopWindow Function

Declare Function GetTopWindow Lib "user32.dll" (ByVal hwnd As Long) As Long

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

GetTopWindow returns a handle to the currently active child window of a window. The active child window is the one that has the focus, and it is usually at the top of all the other children in the Z-order. This function works even if the parent window is not active. If an error occurs or the window has no children, the function instead returns 0. This function is identical to calling GetWindow using the GW_CHILD relationship.

hwnd
The handle of the parent window. The function will return its active child window.

Example:

' Flash the MDI form window MDIForm1's active child once.
' (In VB, a MDI form has child windows).
Dim active As Long  ' receives handle to the MDI form's active window
Dim retval As Long  ' return value used for flashing the child window

active = GetTopWindow(MDIForm1.hWnd)  ' get the handle of MDIForm1's active child window
If active <> 0 Then  ' don't try to flash if there is no child window
  ' The next three lines flags the window once.
  retval = FlashWindow(active, 1): Sleep 250
  retval = FlashWindow(active, 1): Sleep 250
  retval = FlashWindow(active, 0)
End If

See Also: GetWindow
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/gettopwindow.html