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

Related Call: GetWindow
Category: Windows
Back to the index.


Go to Paul Kuliniewicz's Home Page.
E-mail: rogue953@hotmail.com
This page is at http://skyscraper.fortunecity.com/transmission/45/api/g/gettopwindow.html