做项目中间遇到了MDI窗体内边框的问题,经过苦苦寻找,最终得到了解决方案

在Main窗体中调用API

  // Win32 Constants
private const int GWL_STYLE = -;
private const int GWL_EXSTYLE = -;
private const int WS_BORDER = 0x00800000;
private const int WS_EX_CLIENTEDGE = 0x00000200;
private const uint SWP_NOSIZE = 0x0001;
private const uint SWP_NOMOVE = 0x0002;
private const uint SWP_NOZORDER = 0x0004;
private const uint SWP_NOACTIVATE = 0x0010;
private const uint SWP_FRAMECHANGED = 0x0020;
private const uint SWP_NOOWNERZORDER = 0x0200; // Win32 方法
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern int GetWindowLong(IntPtr hWnd, int Index); [DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern int SetWindowLong(IntPtr hWnd, int Index, int Value); [DllImport("user32.dll", ExactSpelling = true)]
private static extern int SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter,
int X, int Y, int cx, int cy, uint uFlags); 获取到API后在Form_Load事件中加入如下代码
  //获取mdi客户区
for (int i = ; i < this.Controls.Count; i++)
{
var mdiClientForm = this.Controls[i] as MdiClient;
if (mdiClientForm == null) continue;
// 找到了mdi客户区
// 取得客户区的边框
int style = GetWindowLong(mdiClientForm.Handle, GWL_STYLE);
int exStyle = GetWindowLong(mdiClientForm.Handle, GWL_EXSTYLE);
style &= ~WS_BORDER;
exStyle &= ~WS_EX_CLIENTEDGE; // 调用win32设定样式
SetWindowLong(mdiClientForm.Handle, GWL_STYLE, style);
SetWindowLong(mdiClientForm.Handle, GWL_EXSTYLE, exStyle); // 更新客户区
SetWindowPos(mdiClientForm.Handle, IntPtr.Zero, , , , ,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
UpdateStyles();
break;
}

重新运行程序,OK

最新文章

  1. iOS Class 使用NSProxy和NSObject设计代理类的差异
  2. RDIFramework.NET开发实例━表约束条件权限的使用-Web
  3. zabbix_监控_端口
  4. sqlmap win32下命令集合
  5. yii生成webapp
  6. php 好用的函数
  7. Kingbase在初始化时遇到的错误
  8. Mac上安装Appium简介
  9. Spring Cloud Zuul 限流详解(附源码)(转)
  10. Springboot 配置类( @Configuration) 不能使用@Value注解从application.propertyes中加载值以及Environment为null解决方案
  11. 【node】node连接mongodb操作数据库
  12. [hadoop] hadoop 运行 wordcount
  13. SAP月末结账年结流程
  14. 一次docker中的nginx进程响应慢问题定位记录
  15. [转]JAVA泛型通配符T,E,K,V区别,T以及Class&lt;T&gt;,Class&lt;?&gt;的区别
  16. 『cs231n』作业2选讲_通过代码理解优化器
  17. Keil C51 的printf
  18. django1.8高级视图和URL配置读书笔记
  19. Python笔试面试题_牛客(待完善)
  20. 8、在Shell脚本中使用函数

热门文章

  1. set类型
  2. 自动化运维工具SaltStack - 多环境(使用记录【state.sls 与 state.highstate】)
  3. tone() 和 IRremote 冲突的解决办法
  4. 无废话XML--XML细节
  5. 基于百度地图SDK和Elasticsearch GEO查询的地理围栏分析系统(3)-前端实现
  6. 豹哥嵌入式讲堂:ARM知识概要杂辑(4)- Cortex-M处理器性能指标
  7. CentOS 7修改网卡名称
  8. linux安全篇
  9. 【转】判断点在多边形内(matlab)
  10. NIO笔记---上