Delphi form function GetTopWindow, GetNextWindow

About this GetWindow function, click the hyperlink  GetWindow

GetTopWindow
  Function: The child window z-order with a specific function checks the parent window associated, and returns a handle to the child window in the top of the z-order.
  The function prototype: HWND GetTopWindow (HWND hWnd);
  Parameters:
  Handle checked parent window sequence: hWnd. If this argument is NULL, the function returns the window handle of the top of the Z order.
  Return value; If the function succeeds, the return value in the top of the Z order of the sub-window handle. If the specified window without sub-windows, the return value is NULL.
  To get extended error information, call GetLastError.
  Quick: Windows NT: 3.1 or later; Windows: 95 or later: Windows CE: not supported; the header file: Winuser.h: libraries; user32.lib.  

// Declare: 
GetTopWindow ( 
  the hWnd: the HWND; specified window handle {} 
): the HWND; {else return 0; Successful return topmost child window handle} 

 

Get the topmost window of operation:

var
  h1,h2: HWND;
begin
  h1 := GetTopWindow(GetDesktopWindow);
  h2 := GetWindow(GetDesktopWindow, GW_CHILD);
  ShowMessage(Format('%d,%d',[h1,h2])); {132540,132540}
end;

 GetDesktopWindow function introduction

 

GetNextWindow
  Function: This function returns a handle to the front or rear window of a sequence in z. In the next window below the specified window, the previous window is at the top. If the specified window is the top of the window, the function returns a next (or previous) to the top of the window handle. If the specified window handle is the top-level window, the function returns a (or previous) top-level window. If the function is a child window handle search for the next or previous child window of the function.
  The function prototype: HWND GetNextWindow (HWND hWnd, UNIT wCmd);
  parameters:
  the hWnd: a window handle. WCmd phase window handle parameter on the basis of the obtained handle for this window.

  wCmd: specified window handle to handle returns or after a window in front of a window. This parameter can be one of the following two values:

  GW HWNONEXT: returns the window handle of the given window below.
  GW_HWNDPREV: Returns the handle to the window above the given window.
  Return Value: If the function succeeds, the return value is the previous window (or a rear window) handle. If the front window does not exist, the return value is NULL. To get extended error information, call GetLastError.
  Note: When setting up GW_HWNDNEXT or GW_GETPREV mark, the function is called with the same calling GetWindow function.
  Quick: Windows NT: 3.1 or later; Windows: 95 or later: Windows CE: Not supported: headers: Winuer.h; library: user32.lib.

// uCmd optional values:
GW_HWNDFIRST = 0; {with the level of the first}
GW_HWNDLAST =. 1; the same level of the last {}
GW_HWNDNEXT = 2; under the same level of {a}
GW_HWNDPREV =. 3; the same level of {a}
GW_OWNER = 4; owner window {}
the GW_CHILD =. 5; sub-window} {

 

 

Created: 2020.01.03 Updated:

Source: https: //www.cnblogs.com/guorongtao/p/12143053.html

 

Guess you like

Origin www.cnblogs.com/guorongtao/p/12143053.html