最近做个项目,动态创建子窗口后发现被父窗口中的一些button所覆盖,晚上查了好久,后来在一个帖子中找到了答案,再次将该帖子整理下,帖子地址(http://bbs.csdn.net/topics/330055738)
子窗口被覆盖的效果图如下:
后来hululuzhu网友给出了一个答案,我试了一下,是正确的,代码如下
using System.Runtime.InteropServices;
[DllImport("user32")]
public static extern int SetParent(int hWndChild, int hWndNewParent);
//价格temp2是你的子form
temp2.MdiParent = this;
temp2.Show();
SetParent((int)temp2.Handle, (int)this.Handle);