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