當(dāng)主窗口的客戶區(qū)部分大小改變時(shí),我們的應(yīng)用程序?qū)⒔邮盏?/span> WM_SIZE 消息。當(dāng)然該窗口第一次顯示時(shí),我們也將接收到該消息。要接收到該消息,主窗口必須有 CS_VREDRAW CS_HREDRAW 風(fēng)格。我們應(yīng)該把縮放編輯控件的動(dòng)作放到此處。我們要把編輯控件變成和我們的窗口客戶區(qū)一樣大,所以先得要得到父窗口客戶區(qū)的大小。這些值包含在參數(shù) lParam 中, lParam 的高字部分是客戶區(qū)的高,底字部分是客戶區(qū)的寬。然后我們調(diào)用 MoveWindow 函數(shù)來重新調(diào)整編輯控件的大小,該函數(shù)不僅能夠移動(dòng)窗口的位置,而且能夠改變窗口的大小。

.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.