3 a message is: wm_size , wm_sizing , Wm_getminmaxinfo and corresponding processing functions are respectively: OnSize , onsizing , OnGetMinMaxInfo .
When the window size changes, the order in which the responses occur is: wm_getminmaxinfo-->wm_sizing-->wm_size .
OnGetMinMaxInfo
This function is called once when the window is initialized and is called when the window size changes. With this function, it is convenient to control the maximum and minimum size of the window.
Parameters Lpmmi is a struct pointer that contains information about the window's maximized size and position, and the minimum and maximum tracking size.
The code for the example that uses this function to control the window's minimum size is as follows:
void Cxxxdlg::ongetminmaxinfo (Minmaxinfo far* Lpmmi)
{
lpmmi->ptmintracksize.x =//x width
lpmmi->ptmintracksize.y =//y Height
?
Cdialog::ongetminmaxinfo (Lpmmi);
}
The above code can make the window size change when the minimum width is 500px , the minimum height is 100px .
Onsizing
This function is called when the window size is changed. In this function, the maximum minimum size of the window can also be controlled, but no ongetminmaxinfo is convenient.
void Cxxxdlg::onsizing (UINT fwside, LPRECT prect)
{
if ((Prect->right-prect->left) < 500)
{
//return;// directly return is invalid. , the window size will still change
Prect->right = Prect->left + 500;
}
?
Cdialog::onsizing (Fwside, prect);
}
with the above method, if you change the size from the right, you can achieve the desired effect, but change the size from the left, although the size can be controlled in the smallest - , but when the minimum width is reached and then zoomed out, the entire window is moved to the right, because the code prect->right = Prect->left +; This sentence is for Left to change Right of, so Left moved on, Right also moved, it looked as if the window had shifted right. Therefore, in order to deal with this situation, another corresponding treatment.
OnSize
This function is called after the window size is changed, and the position and size of each control is usually rearranged in this function. With this function, there is no way to control the maximum minimum size of the window.
C + +: Window Change-related messages OnSize, onsizing, and ongetminmaxinfo,onsizeonsizing