[英]How to remove control box from MDIchild form
当我在MDIparent
加载子窗体时,控制框也会出现。 我要删除控制框和子窗体的边框。 我也在写代码
private void Form_mainMenu_Load(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Maximized;
this.ControlBox = false;
this.FormBorderStyle = FormBorderStyle.None;
}
如果确实要自定义mdiChild窗口标题栏的外观,则似乎需要通过处理WM_NCPAINT
消息来处理子窗口非客户区域的WM_NCPAINT
。 另外,您还需要处理WM_SETCURSOR
, WM_MOUSEMOVE
, WM_NCLBUTTONDOWN
等消息。
解决方法是,可以使用面板而不是mdiParent。
IsMdiContainer
。 Dock
属性设置为fill。 这是示例代码:
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();
使用这种方法,您可以控制手工MDI窗口的各个方面。 例如,您可以使用菜单显示打开的窗口列表,并使用工具栏关闭窗口。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.