如何去除MDIchild形式控制箱 [英] How to remove control box from MDIchild form
问题描述
当我加载在的MdiParent
子窗体也出现在控制箱。我想删除的控制箱及子窗体的边界。
我也正在写代码
私人无效Form_mainMenu_Load(对象发件人,EventArgs五)
{
this.WindowState = FormWindowState.Maximized;
this.ControlBox = FALSE;
this.FormBorderStyle = FormBorderStyle.None;
}
如果你真的想定制mdiChild窗口的标题栏的外观,看来你需要通过处理 WM_NCPAINT
信息处理子窗口的非客户区的画。
你也需要处理,比如 WM_SETCURSOR
, WM_MOUSEMOVE
, WM_NCLBUTTONDOWN 消息code> ...
您也可以使用面板代替的MdiParent一种解决方法。
- 创建父窗体,并没有设置
的IsMdiContainer
。 - 添加面板到父窗体并命名为ContainerPanel,并设置其
码头
属性来填补。 - 创建您的孩子的形式,并与无边框添加到面板风格,没有控制中,填写码头风格和非顶层
下面是示例代码:
变种F =新ChildForm();
f.TopLevel = FALSE;
f.ControlBox = FALSE;
f.Dock = DockStyle.Fill;
f.BorderStyle = System.Windows.Forms.BorderStyle.None;
/ *我认为这个代码是在你的ParentForm等这个指向包含ContainerPanel * /
this.ContainerPanel.Controls.Add ParentForm(F);
f.Show();
使用这样的方法,你可以控制你的手的各个方面取得的MDI窗口。例如,你可以使用菜单显示打开的窗口列表和工具条关闭窗口。
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;
}
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.
- Create parent form and don't set
IsMdiContainer
. - Add a panel to your parent form and name it "ContainerPanel" and set its
Dock
property to fill. - 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.
这篇关于如何去除MDIchild形式控制箱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!