当主窗口的客户区部分大小改变时,我们的应用程序将接收到 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.