用C#制作 个性化窗体 winform 界面 联系客服

发布时间 : 星期日 文章用C#制作 个性化窗体 winform 界面更新完毕开始阅读f13832e819e8b8f67c1cb9c7

tlhx 级: C# code 民百姓) 多勋章 public partial class NoBorder : Form { internal static int WM_NCHITTEST = 0x84; //移动鼠标,按住或释放鼠标时发生的系统 internal static IntPtr HTCLIENT = (IntPtr)0x1;//工作区 internal static IntPtr HTSYSMENU = (IntPtr)3;//系统菜单 internal static IntPtr HTCAPTION = (IntPtr)0x2; //标题栏 private int m_BorderWidth = 2; private int m_CaptionHeight = 22; public NoBorder() { this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaontrolStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true); InitializeComponent(); this.Padding = new Padding(this.m_BorderWidth, this.m_BorderWidth + thisionHeight, this.m_BorderWidth, this.m_BorderWidth); } protected override CreateParams CreateParams { get { int WS_SYSMENU = 0x00080000; int WS_MAXIMIZEBOX = 0x10000; int WS_MINIMIZEBOX = 0x20000; int WS_THICKFRAME = 0x40000; CreateParams cp = base.CreateParams; cp.Style |= WS_SYSMENU | 0x20000 | WS_MINIMIZEBOX | WS_MAXIMIZEB_THICKFRAME; return cp; } } ///

/// 重写以处理模拟鼠标系统处理 ///

/// rect.Top + m_BorderWidth && cp.Y <= rect.Top tionHeight + m_BorderWidth && cp.X > rect.Left + m_BorderWidth && cp.X < rect.Ri_BorderWidth) { if ((cp.X <= rect.Left + m_BorderWidth + m_Captit)) { m.Result = HTSYSMENU;//模拟系统菜单,双击可窗体 } else { m.Result = HTCAPTION;//模拟标题栏,移动或双最大或最小化窗体 } } } return; } base.WndProc(ref m);

} ///

/// 绘制窗体 /// /// /// 重写以处理鼠标按钮准备调整窗体大小 /// ///

///

/// 重写以处理鼠标抬起事件重置状态 /// /// /// 重写以处理鼠标移动调整窗体大小位置 /// ///