A desktop is typically regarded as a two-dimensional display space; in fact, a desktop is three-dimensional, since when windows overlap on the desktop, one window is conceptually "on top of" the other. This concept of "stacking" windows applies even when windows do not actually overlay one another on the desktop. The order in which windows appear on the desktop is known as the z-order. The z-order is known to Presentation Manager, and a number of function calls are provided that enable an application to request window handles of specific windows in the z-order using the WinGetNextWindow() function to obtain the handle of the next window in the z-order, or the WinQueryWindow() function to obtain the handle of a window at a specified position in the z-order.
Since the z-order changes dynamically as different applications create and destroy windows, Presentation Manager takes a "snapshot" of the desktop state when the application issues a WinBeginEnumWindows() call. This function accepts a window handle as a parameter, and the z-order of all immediate children of that window is recorded by Presentation Manager. A call to this function should be issued before any WinGetNextWindow() call is issued, or before any WinQueryWindow() call is issued that specifies a position in the z-order. When the application no longer wishes to interrogate the recorded window hierarchy, a WinEndEnumWindows() call should be made.
The concepts of z-order and window enumeration are useful in circumstances where an operation or sequence of operations must be performed on a number of windows in order. Windows with the same parent always appear contiguously in the z-order, and thus may be easily processed in succession.