mdi子窗口在父窗口其他控件之上显示

来源:互联网 发布:巴西利亚 知乎 编辑:程序博客网 时间:2024/05/17 00:06

做个东西用到mdi父子窗口,但是子窗口总是出现在父窗口其他控件的下面,不能显示出来。

通过引用win32 api可以解决。

1, 添加引用using System.Runtime.InteropServices;

2, 定义 [DllImport("User32.dll")]
        public static extern IntPtr SetParent(IntPtr hchild, IntPtr hparent);

3,     调用时,在父窗口对show子窗口的调用使用该api。

          //saveForm.Show();原来的方法,注释掉
         SetParent(saveForm.Handle, splitContainer.Panel2.Handle);//改成这种,splitContainer.Panel2为父窗口的控件

原创粉丝点击