C + +: Window Change-related messages OnSize, onsizing, and ongetminmaxinfo,onsizeonsizing

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.