WM_SIZE message
Sent to a window after its size has changed.
A window receives this message through its WindowProc function.
#define WM_SIZE 0x0005
-
wParam
-
The type of resizing requested. This parameter can be one of the following values.
Value Meaning - SIZE_MAXHIDE
- 4
Message is sent to all pop-up windows when some other window is maximized. - SIZE_MAXIMIZED
- 2
The window has been maximized. - SIZE_MAXSHOW
- 3
Message is sent to all pop-up windows when some other window has been restored to its former size. - SIZE_MINIMIZED
- 1
The window has been minimized. - SIZE_RESTORED
- 0
The window has been resized, but neither the SIZE_MINIMIZED nor SIZE_MAXIMIZED value applies. -
lParam
-
The low-order word of lParam specifies the new width of the client area.
The high-order word of lParam specifies the new height of the client area.
Type: LRESULT
If an application processes this message, it should return zero.
/******************************************************************
* *
* SimpleText::OnResize *
* *
* If the application receives a WM_SIZE message, this method *
* resize the render target appropriately. *
* *
******************************************************************/
void SimpleText::OnResize(UINT width, UINT height)
{
if (pRT_)
{
D2D1_SIZE_U size;
size.width = width;
size.height = height;
pRT_->Resize(size);
}
}
LRESULT CALLBACK SimpleText::WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
SimpleText *pSimpleText = reinterpret_cast<SimpleText *>(
::GetWindowLongPtr(hwnd, GWLP_USERDATA));
if (pSimpleText)
{
switch(message)
{
case WM_SIZE:
{
UINT width = LOWORD(lParam);
UINT height = HIWORD(lParam);
pSimpleText->OnResize(width, height);
}
return 0;
// ...
Example from Windows classic samples on GitHub.
If the SetScrollPos or MoveWindow function is called for a child window as a result of the WM_SIZE message, the bRedraw or bRepaint parameter should be nonzero to cause the window to be repainted.
Although the width and height of a window are 32-bit values, the lParam parameter contains only the low-order 16 bits of each.
The DefWindowProc function sends the WM_SIZE and WM_MOVE messages when it processes the WM_WINDOWPOSCHANGED message. The WM_SIZE and WM_MOVE messages are not sent if an application handles the WM_WINDOWPOSCHANGED message without calling DefWindowProc.
Requirement | Value |
---|---|
Minimum supported client |
Windows 2000 Professional [desktop apps only] |
Minimum supported server |
Windows 2000 Server [desktop apps only] |
Header |
|
-
Reference
-
Conceptual
-
Other Resources