概述
當主視窗的客戶區部分大小改變時,我們的應用程式將接收到 WM_SIZE 訊息。當然該視窗第一次顯示時,我們也將接收到該訊息。我們應該把縮放編輯控制項的動作放到此處。我們要把編輯控制項變成和我們的視窗客戶區一樣大,所以先得要得到父視窗客戶區的大小。這些值包含在參數 lParam 中, lParam 的高字部分是客戶區的高,低字部分是客戶區的寬。然後我們調用 MoveWindow 函式來重新調整編輯控制項的大小,該函式不僅能夠移動視窗的位置,而且能夠改變視窗的大小。
參數說明
Specifies the type of resizing requested.
通常用來向別的視窗傳送訊息時,需要指定的附加信息
Value | Meaning |
SIZE_MAXHIDE | Message is sent to all pop-up windows when some other window is maximized. |
SIZE_MAXSHOW | Message is sent to all pop-up windows when some other window has been restored to its former size. |
SIZE_MINIMIZED | The window has been minimized. |
SIZE_MAXIMIZED | Window has been maximized. |
SIZE_RESTORED | The window has been resized, but neither the SIZE_MINIMIZED nor SIZE_MAXIMIZED value applies. |
lParam:
The low-order word of lParamspecifies the new width of the client area.
The high-order word of lParam specifies the new height of the client area.
note:
lParam和
GetClientRect的功能一樣,有時候WM_SIZE的效率要比使用GetClientRect高. 可以在程式中使用WM_SIZE來保存Client area的大小方便以後使用.
WM_SIZE附帶的信息:
WM_SIZE
fwSizeType = wParam; // resizing flag
nWidth = LOWORD(
lParam); // width of client area
nHeight = HIWORD(lParam); // height of client area
告訴我們Windows處理視窗大小變化後新視窗客戶區的大小.
Message Cracker
void Cls_OnSize(HWND hwnd, UINT state, int cx, int cy)