WinForm go down except MDI form border

Source: Internet
Author: User

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

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.