An application can move a window to the top or bottom of the z-order by passing the SWP_ZORDER constant to the WinSetWindowPos function. An application specifies where to move the window by specifying the HWND_TOP or HWND_BOTTOM constants.
The code fragment in the following figure uses WinSetWindowPos to change the z-order of a window.
HWND hwndParent; HWND hwndNext; HENUM henum; WinSetWindowPos( hwndNext, /* Next window to move */ HWND_TOP, /* Put window on top */ 0, 0, 0, 0, /* Not used for z-order */ SWP_ZORDER); /* Change z-order */
An application also can specify the window that the given window is to move behind. In this case, the application specifies the window handle instead of the HWND_TOP or HWND_BOTTOM constant.
HWND hwndParent; HWND hwndNext; HWND hwndExchange; HENUM henum; henum = WinBeginEnumWindows(hwndParent); hwndExchange = WinGetNextWindow(henum); /* hwndNext has top window; hwndExchange has window under the top. */ WinSetWindowPos( hwndNext, /* Next window to move */ hwndExchange, /* Put lower window on top */ 0, 0, 0, 0, /* Not used for z-order */ SWP_ZORDER); /* Change z-order */ WinEndEnumWindows(henum);