Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
697 views
in Technique[技术] by (71.8m points)

c# - How to remove control box from MDIchild form

When I'm loading a child form in MDIparent the control box also appears. I want to remove the control box and the border of child form. Also I'm writing code as

private void Form_mainMenu_Load(object sender, EventArgs e)
{
     this.WindowState = FormWindowState.Maximized;
     this.ControlBox = false;
     this.FormBorderStyle = FormBorderStyle.None;
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you really want to customize the appearance of title bar of mdiChild Window, it seems you need handle painting of non-client areas of child window by handling WM_NCPAINT message. Also you need to handle messages like WM_SETCURSOR, WM_MOUSEMOVE, WM_NCLBUTTONDOWN, ... .

As a workaround you can use a panel instead of mdiParent.

  1. Create parent form and don't set IsMdiContainer.
  2. Add a panel to your parent form and name it "ContainerPanel" and set its Dock property to fill.
  3. Create your child form and add it to panel with none border style, no control box, fill dock style and non top level.

Here is sample code:

var f = new ChildForm();
f.TopLevel = false;
f.ControlBox = false;
f.Dock = DockStyle.Fill;
f.BorderStyle = System.Windows.Forms.BorderStyle.None;

/*I assume this code is in your ParentForm and so 'this' points to ParentForm that contains ContainerPanel*/
this.ContainerPanel.Controls.Add(f);
f.Show();

Using such method you can control every aspect of your hand made mdi window. For example you can use a Menu to show list of open windows and a toolstrip to close windows.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...