【C#】vs父窗体控件覆盖子窗体

前因

在重构的过程中使用单例模式,单例模式使用成功之后新的问题又出现了,父窗体的控件覆盖了子窗体,这种视觉效果……

知识点介绍

  • user32.dll

user32.dll是Windows用户界面相关应用程序接口,用于包括Windows处理,基本用户界面等特性,如创建窗口和发送消息。

  • using System.Runtime.InteropServices;

System.Runtime.InteropServices 命名空间提供各种各样支持 COM interop 及平台调用服务的成员,此命名空间提供了多种类别的功能。

解决方法

  • 添加引用
using System.Runtime.InteropServices;
  • 导入user32类库
 [DllImport("user32")]//导入user32类库
  • 声明外部方法
 public static extern int SetParent(int children, int parent);//声明外部方法
  • 调用
UI.frmRegister frm = frmRegister.GetInstance();
            frm.MdiParent = this;
            frm.Show();
            SetParent((int)frm.Handle, (int)this.Handle);

小结

生活中的很多事情只要再坚持一下,便是胜利!

 

猜你喜欢

转载自blog.csdn.net/qq2263796380/article/details/87928255