MFC tip One: Set the dialog box to no border no title bar initial maximized style

Source: Internet
Author: User
Tags bitwise

Today the company started a new project. The interface mode is an initial maximized style without a border without a title bar. In fact, it can be directly in the properties of the default resizing can be changed to none, then I want to use code to achieve it? So Baidu a bit. Two ways have been found, but in fact the ideas are the same in both ways. That is, modify the style--modifystyle. Add the following code directly to OnInitDialog ().

The first type:

1 //Remove title bar2ModifyStyle (Ws_caption,0); 3  //Remove Border4ModifyStyleEx (Ws_ex_dlgmodalframe,0); 5 //window position and size remain the same6SetWindowPos (NULL,0,0,0,0, Swp_nosize | Swp_nomove | Swp_nozorder |swp_framechanged); 7 //Maximize Window8ShowWindow (sw_maximize);
View Code

The second type:

1 //Get Old Style2DWORD dwstyle =GetStyle ();3DWORD Dwnewstyle = ws_overlapped | ws_visible| Ws_sysmenu | Ws_minimizebox| Ws_maximizebox| ws_clipchildren|ws_clipsiblings;4 //bitwise AND remove old styles5dwnewstyle&=dwstyle;6 //set into a new style7 SetWindowLong (m_hwnd,gwl_style,dwnewstyle);8 //get old extended styles9DWORD dwExStyle =Getexstyle ();TenDWORD Dwnewexstyle = Ws_ex_left | ws_ex_ltrreading |Ws_ex_rightscrollbar; One //bitwise AND remove old extended styles Adwnewexstyle&=dwExStyle; - //to set a new extended style - SetWindowLong (m_hwnd,gwl_exstyle,dwnewexstyle); the //window position and size remain the same -SetWindowPos (NULL,0,0,0,0, swp_nozorder| swp_nomove| swp_nosize|swp_framechanged); - //Maximize Window -ShowWindow (sw_maximize);
View Code

At present, there are no other sequelae in either of these ways, so simplicity seems to be the first of the best.

Reference blog:

Http://blog.csdn.net/hurryboylqs/article/details/5525597#comments

http://blog.csdn.net/CKRGD/article/details/48372913

http://blog.csdn.net/visualeleven/article/details/19543391

MFC tip One: Set the dialog box to no border no title bar initial maximized style

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.