當主窗口的客戶區部分大小改變時,我們的應用程序將接收到 WM_SIZE 消息。當然該窗口第一次顯示時,我們也將接收到該消息。要接收到該消息,主窗口必須有 CS_VREDRAW CS_HREDRAW 風格。我們應該把縮放編輯控件的動作放到此處。我們要把編輯控件變成和我們的窗口客戶區一樣大,所以先得要得到父窗口客戶區的大小。這些值包含在參數 lParam 中, lParam 的高字部分是客戶區的高,底字部分是客戶區的寬。然后我們調用 MoveWindow 函數來重新調整編輯控件的大小,該函數不僅能夠移動窗口的位置,而且能夠改變窗口的大小。

.ELSEIF uMsg==WM_SIZE
??mov eax,lParam????????????? ;低16位寬,高16位高
??mov edx,eax
??shr edx,16????????????????? ;IParam邏輯右移16位,保留高16位,即高
??and eax,0ffffh????????????? ;高16位清0,保留低16位,即寬
??invoke MoveWindow,hwndEdit,0,0,eax,edx,TRUE

WM_SIZE

The WM_SIZE message is sent to a window after its size has changed.

A window receives this message through its WindowProc function.

LRESULT CALLBACK WindowProc(
HWND hwnd,       // handle to window
UINT uMsg,       // WM_SIZE
WPARAMwParam,   // resizing flag
LPARAMlParam    // client area
);

Parameters

wParam
Specifies the type of resizing requested. This parameter can be one of the following values.
ValueMeaning
SIZE_MAXHIDEMessage is sent to all pop-up windows when some other window is maximized.
SIZE_MAXIMIZEDThe window has been maximized.
SIZE_MAXSHOWMessage is sent to all pop-up windows when some other window has been restored to its former size.
SIZE_MINIMIZEDThe window has been minimized.
SIZE_RESTOREDThe 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.

Return Values

If an application processes this message, it should return zero.