WM_NCCALCSIZE
The
WM_NCCALCSIZE message is sent when the size and position of a window s client
area must be calculated. By processing this message, an application can control
the content of the window s client area when the size or position of the window
changes.
WM_NCCALCSIZE
fCalcValidRects = (BOOL) wParam; // valid area flag
lpncsp = (LPNCCALCSIZE_PARAMS) lParam; // points to size calculation data
or
lpncsp = (LPRECT) lParam; // points to new window
coordinates
Parameters
fCalcValidRects
Value of wParam.
A Boolean value that, if TRUE, specifies that the application should indicate
which part of the client area contains valid information. The operating system
copies the valid information to the specified area within the new client area.
Also, if this parameter is TRUE, lParam points to an NCCALCSIZE_PARAMS
If this
parameter is FALSE, the application does not need to indicate the valid part of
the client area. Also, if this parameter is FALSE, lParam points to a RECT
lpncsp
Value of lParam.
If wParam is TRUE, lParam points to an NCCALCSIZE_PARAMS structure that contains
information an application can use to calculate the new size and position of
the client rectangle.
If wParam is FALSE, lParam points to a RECT structure that contains the
new coordinates of the window that has been moved or resized. This is
equivalent to rgrc[0] of an NCCALCSIZE_PARAMS structure.
Return Values
If the fCalcValidRects
parameter is FALSE, the application should return zero.
If fCalcValidRects
is TRUE, the application can return zero or a valid combination of the
following values:
Value |
Meaning |
WVR_ALIGNTOP,
WVR_ALIGNLEFT, WVR_ALIGNBOTTOM, WVR_ALIGNRIGHT |
|
|
These values,
used in combination, specify that the client area of the window is to be
preserved and aligned appropriately relative to the new position of the
window. For example, to align the client area to the lower-left corner,
return the WVR_ALIGNLEFT and WVR_ALIGNTOP values. |
WVR_HREDRAW,
WVR_VREDRAW |
|
|
These
values, used in combination with any other values, cause the window to be
completely redrawn if the client rectangle changes size horizontally or
vertically. These values are similar to the CS_HREDRAW and CS_VREDRAW class
styles. |
WVR_REDRAW |
|
|
This value
causes the entire window to be redrawn. It is a combination of WVR_HREDRAW
and WVR_VREDRAW values. |
WVR_VALIDRECTS |
|
|
This value
indicates that, upon return from WM_NCCALCSIZE, the rectangles specified by
the rgrc[1] and rgrc[2] members of the NCCALCSIZE_PARAMS |
|
This return
value allows an application to implement more elaborate client-area
preservation strategies, such as centering or preserving a subset of the
client area. |
If fCalcValidRects
is TRUE and an application returns zero, the old client area is preserved and
is aligned with the upper-left corner of the new client area.
Default Action
The window
may be redrawn, depending on whether the CS_HREDRAW or CS_VREDRAW class style
is specified. This is the default, backward-compatible processing of this message
by the DefWindowProc function (in addition to the usual client rectangle
calculation described in the preceding table).
See Also