|
The function of the SetWindowPos function is to move a window in three-dimensional space. With it, you can change the position of a window, even on the Z axis (the Z axis determines the relationship between a window and other windows), and you can also change the window size of. In order to realize the TopMost type of window, we only need to call this function, put the window in front of all windows and always keep it on top.
DWORD_PRT SetWindowPos(HWND hWnd,HWND hInsertAfter,int x,int y,int cx,int cy,UINT nFlag)
Table 1 Parameter explanation of SetWindowPos function
Parameter name Parameter meaning
hwnd The handle of the window to be moved (you can use the hwnd attribute of the form)
hWndInsertAfter marks on how to place the window on the Z axis (see Table 2 for details)
x is equivalent to the Left property of the window
y is equivalent to the Top property of the window
cx is equivalent to the Right property of the window
cy is equivalent to the Bottom property of the window
wFlags flags on how to move the window (see Table 3 for details)
Table 2 Possible values and meanings of the HWndInsertAfter parameter
Possible values of hWndInsertAfter Function
The handle of a window puts the window behind the window specified by the handle
HWND_BOTTOM(1) Put the window at the end of the Z axis, that is, behind all windows
HWND_TOP(0) Put the window in front of the Z axis, that is, in front of all windows
HWND_TOPMOST(-1) makes the window a "TopMost" type window, this type
The window is always in front of other windows, so it is closed
HWND_NOTOPMOST(-2) Put the window in all "TopMost" types
Behind the window, in front of other types of windows
Table 3 Possible values and meanings of wFlags parameters
Possible values of wFlags parameter Function
SWP_DRAWFRAME(&H20) Redraw the window and all its contents after moving the window
SWP_HIDEWINDOW(&H80) Hides the window. After the window is hidden, it will neither appear on the screen nor at any time.
Taskbar, but it is still active
SWP_NOACTIVATE(&H10) does not activate the window after the window is moved, of course, if the window is before the move
Active exception
SWP_NOCOPYBITS(&H100) When the window is moved, do not redraw any content on it
SWP_NOMOVE(&H2) does not move the window (ie ignore the X and Y parameters)
SWP_NOSIZE(&H1) does not change the window size (ie ignores the Cx and Cy parameters)
SWP_NOREDRAW(&H8) Do not remove the image of the window in its former position
from the screen. In other words,leave behind a ghost image
of the window in its old position
SWP_NOZORDER(&H4) does not change the window to listen to the Z axis position (that is, ignore the hWndInsertAfter parameter)
SWP_SHOWWINDOW(&H40) display window (SWP_HIDEWINDOW must be used before
Hidden window)
The parameters are very complicated, and you will find the answer if you look at it slowly. |
|