.NET下,MDI窗体内客户区的3D边框很难看,下面是我写的一个类,可以去掉这个边框:
using
System;
using System.Runtime.InteropServices;
namespace iUNS
{
/// <summary>
/// iuSetMdiClientBorder 的摘要说明。
/// </summary>
public class iuSetMdiClientBorder
{
[DllImport( " user32.dll " , CharSet = CharSet.Auto)]
public static extern int GetWindowLong( int hwnd, int nIndex);
[DllImport( " user32.dll " , CharSet = CharSet.Auto)]
public static extern int SetWindowLong( int hwnd, int nIndex, int dwNewLong);
private const int GWL_EXSTYLE = ( - 20 );
private const int WS_EX_CLIENTEDGE = 0x0200 ;
public iuSetMdiClientBorder()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
/// <summary>
/// 设置Mdi窗口客户区是否绘制3D边框
/// </summary>
/// <param name="hWnd"> Mdi窗口的Handle </param>
/// <param name="showBorder"> 是否绘制3D边框 </param>
public static void SetMdiClientBorder( int hWnd, bool showBorder)
{
int windowLong = GetWindowLong(hWnd,GWL_EXSTYLE);
if (showBorder)
windowLong = windowLong & WS_EX_CLIENTEDGE;
else
windowLong = windowLong & ~ WS_EX_CLIENTEDGE;
SetWindowLong(hWnd, GWL_EXSTYLE, windowLong);
}
}
}
using System.Runtime.InteropServices;
namespace iUNS
{
/// <summary>
/// iuSetMdiClientBorder 的摘要说明。
/// </summary>
public class iuSetMdiClientBorder
{
[DllImport( " user32.dll " , CharSet = CharSet.Auto)]
public static extern int GetWindowLong( int hwnd, int nIndex);
[DllImport( " user32.dll " , CharSet = CharSet.Auto)]
public static extern int SetWindowLong( int hwnd, int nIndex, int dwNewLong);
private const int GWL_EXSTYLE = ( - 20 );
private const int WS_EX_CLIENTEDGE = 0x0200 ;
public iuSetMdiClientBorder()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
/// <summary>
/// 设置Mdi窗口客户区是否绘制3D边框
/// </summary>
/// <param name="hWnd"> Mdi窗口的Handle </param>
/// <param name="showBorder"> 是否绘制3D边框 </param>
public static void SetMdiClientBorder( int hWnd, bool showBorder)
{
int windowLong = GetWindowLong(hWnd,GWL_EXSTYLE);
if (showBorder)
windowLong = windowLong & WS_EX_CLIENTEDGE;
else
windowLong = windowLong & ~ WS_EX_CLIENTEDGE;
SetWindowLong(hWnd, GWL_EXSTYLE, windowLong);
}
}
}
本文转自 OldHawk 博客园博客,原文链接:http://www.cnblogs.com/taobataoma/archive/2007/04/30/733252.html
,如需转载请自行联系原作者