C#中子窗体如何覆盖在父窗体容器中的所有控件上

怎么就能把“Form_学习查询”这个窗体压在“班级公告”这些在父窗体中的控件上了?

using System.Runtime.InteropServices;

 [DllImport("user32")]
 public static extern int SetParent(int hWndChild, int hWndNewParent);

 调用:

   Form2 f2 = new Form2();
   f2.MdiParent = this;
   f2.Show();
   SetParent((int)f2.Handle, (int)this.Handle);

 

上两位说的 TopMost 是错误的,题主自己试验即可。

追问

[DllImport("user32")]
public static extern int SetParent(int hWndChild, int hWndNewParent);

这个是写在哪啊?麻烦给解释一下吧……谢了……

追答

API 函数声明,任意一个过程外部即可,如下图:

 

温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-11-06
上楼正解,设置窗体的属性TopMost为True,则该窗体将会置顶。
第2个回答  2017-12-23
可是这个函数要怎么实现呀
第3个回答  2013-11-06
设置窗体置顶TopMost
相似回答