MFC disable window maximization button and disable window size change

Source: Internet
Author: User

1. Modify the precreatewindow () function as follows:

Bool cmainframe: precreatewindow (createstruct & CS)

{

If (! Cframewnd: precreatewindow (CS) return false;

CS. dwexstyle & = ~ Ws_ex_clientedge;

CS. Style & = ~ Ws_maximizebox; // disable window Maximization

CS. Style & = ~ Ws_minimizebox; // disable window Minimization

// CS. Style & = ~ Ws_sysmenu; // cancel the button on the title

CS. Style & = ~ Ws_thickframe; // The window size cannot be changed with the mouse

CS. lpszclass = afxregisterwndclass (0 );

Return true;

}

2. Change the default window size of vc2010 MFC 

2. 1. Because vs2010 will write some information into the registry, this is not the same as vs2005 and vs2008 (excluding SP1). The default SDI and MDI are some BCG-related items.
To modify the window size, you can directly change the window size in the initinstance of the app class before showwindow () and updatewindow (), for example, m_pmainwnd-> movewindow (crect (100,100,600,400), false );

2.2 Application of MFCProgramThere are many differences between the wizard in vc6.0 and vs2010. The MFC Application Wizard in vs2010 adds many new options. By default, when an MFC application is created, the size of the Cx and Cy windows remains unchanged in precreatewindow, in the second step of the vs2010 MFC Application Wizard, select the MFC standard, and in step 6th select the classic menu. The effect is the same as that produced by vc6.0.

 

To sum up:

Write the followingCode:

M_pmainwnd-> movewindow (100, 50,110 0, 550, false );

You can modify the default window size.

 

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.