How to set the size of the client area in the window

Source: Internet
Author: User

In other words, the Windows SDK does not seem to provide an API for setting the size of the customer zone in a window.
Setwindowpos and movewindow can only set the size of the entire window.
You cannot directly set the size of the customer zone. Setting the size of the customer zone is not helpful,
For example, when performing text output computing on the customer area.
Windows window consists of several parts, including the customer, non-customer area, getwindowrect can
Obtains the size of the entire window. getclientrect can be used to obtain the size of the customer. It is important to know that
The size of the customer zone, which can be obtained through getsystemmetrics, is relative to the method below.
It must be complex. Here is my solution:
0) variable definition
Rect rcwindow;-> size of the entire window
Rect rcclient;-> customer zone size
Int borderwidth, borderheight;-> non-customer size

1) Get the size of the entire window through getwindowrect
Getwindowrect (hwnd, & rcwindow );

2) Get the size of the customer's rectangle through getclientrect
Getclientrect (hwnd, & rcclient );

3) subtract the two to obtain the non-customer size.
Borderwidth = (rcwindow. right-rcWindow.left)
-(Rcclient. right-rcClient.left );
Borderheight = (rcwindow. bottom-rcWindow.top)
-(Rcclient. bottom-rcClient.top );

4) use setwindowpos/movewindow to reset the window size
Setwindowpos (hwnd, 0, boderwidth + width of the new customer zone,
Boderheight + new customer height, swp_nomove | swp_nozorder );

Conclusion:
This method cleverly avoids calling system functions to calculate non-customer sizes,
Besides, before calling the API, you need to know the composition of non-customers. This is too complicated.
It is unclear.

Girl don't cry (QQ: 191035066) @ 2013-03-21 23:45:22 http://www.cnblogs.com/nbsofer

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.