Create window size

Source: Internet
Author: User
Tags win32 window

In Windows, the width and height of the Win32 window are determined when the window is created. If the size we set is only the customer area of the window (like a common Direct3D window Program), the accepted size is the size of the entire window because the CreateWindow is called directly, this will make the actual customer region smaller than we imagined. This is because in addition to the customer area, the actual window may also contain borders and title bars. This part actually occupies space, which causes the customer area to be compressed.

To accurately create the size of the customer area, you must calculate the size of the window containing the border and title bar before passing it to CreateWindow.

 

 1 DWORD window_style;
2 // specify that the created window contains the title bar and border (WS_CAPTION itself contains WS_BORDER)
3 // in reality, it is found that there is no difference even if WS_CAPTION is not specified.
4 window_style = WS_SYSMENU | WS_CAPTION;
5
6 // create a window with a size of 100,100*512 in (512)
7 int x = 100, y = 100;
8 int width = 512, height = 512;
9
10 // calculate the final window size
11 RECT window_rect;
12 SetRect (& window_rect, x, y, x + width, y + height );
13 AdjustWindowRect (& window_rect, window_style, FALSE );

 

Pass window_rect returned by AdjustWindowRecet to CreateWindow to create a correct window.

 

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.