In the middle of the project encountered an MDI window inside the border problem, after hard to find, and finally got the solution
Calling the API in the main form
//Win32 Constants Private Const intGwl_style =- -; Private Const intGwl_exstyle =- -; Private Const intWs_border =0x00800000; Private Const intWs_ex_clientedge =0x00000200; Private Const UINTSwp_nosize =0x0001; Private Const UINTSwp_nomove =0x0002; Private Const UINTSwp_nozorder =0x0004; Private Const UINTSwp_noactivate =0x0010; Private Const UINTSwp_framechanged =0x0020; Private Const UINTSwp_noownerzorder =0x0200; //Win32 Method[DllImport ("user32.dll", CharSet =CharSet.Auto)]Private Static extern intGetWindowLong (IntPtr hWnd,intIndex); [DllImport ("user32.dll", CharSet =CharSet.Auto)]Private Static extern intSetWindowLong (IntPtr hWnd,intIndex,intValue); [DllImport ("user32.dll", exactspelling =true)] Private Static extern intSetWindowPos (IntPtr hWnd, IntPtr hwndinsertafter,intXintYintCxintCyUINTUflags);
Add the following code to the Form_Load event after getting to the API
//get MDI client area for(inti =0; I < This. Controls.Count; i++) { varMdiclientform = This. Controls[i] asmdiclient; if(Mdiclientform = =NULL)Continue; //MDI client area found//get border of customer area intstyle =GetWindowLong (Mdiclientform.handle, Gwl_style); intExStyle =GetWindowLong (Mdiclientform.handle, Gwl_exstyle); Style&= ~Ws_border; ExStyle&= ~Ws_ex_clientedge; //call Win32 to set styleSetWindowLong (Mdiclientform.handle, Gwl_style, STYLE); SetWindowLong (Mdiclientform.handle, Gwl_exstyle, ExStyle); //Update Customer AreaSetWindowPos (Mdiclientform.handle, IntPtr.Zero,0,0,0,0, Swp_noactivate| Swp_nomove | Swp_nosize | Swp_nozorder |Swp_noownerzorder|swp_framechanged); UpdateStyles (); Break; }
Re-run the program, OK
WinForm go down except MDI form border