From 9d06e8fcf4ece5af211cfd51c5497d84f944628a Mon Sep 17 00:00:00 2001 From: wyf Date: Tue, 20 May 2025 08:23:20 +0000 Subject: [PATCH] SVN r609 SVN-Revision: r609 --- 插件库/Lskj.Main/FrmMain.cs | 99 ++++++++++++++++++++++--------------- 1 file changed, 60 insertions(+), 39 deletions(-) diff --git a/插件库/Lskj.Main/FrmMain.cs b/插件库/Lskj.Main/FrmMain.cs index e5be97c..7f1564d 100644 --- a/插件库/Lskj.Main/FrmMain.cs +++ b/插件库/Lskj.Main/FrmMain.cs @@ -132,7 +132,8 @@ namespace Lskj.Main this.TheMemoryTest.Start(); } this.mainPanelControlEx.State = this.WindowState; - this.MouseMove += FrmMain_MouseMove; + this.MouseMove += OnFrmMainMouseMove; + this.MouseLeave += OnFrmMainMouseLeave; if (SystemInfo.Instance.DisplayWatermark) @@ -162,7 +163,55 @@ namespace Lskj.Main } } + private void OnFrmMainMouseLeave(object sender, EventArgs e) + { + Cursor = Cursors.Arrow;// 移出窗体变为正常 + } + private void OnFrmMainMouseMove(object sender, MouseEventArgs e) + { + if (WindowState == FormWindowState.Maximized) + { + return; + } + if (e.Button == MouseButtons.Left)//左键按下移动,拖拽调整大小 + { + // MousePosition的参考点是屏幕的左上角,表示鼠标当前相对于屏幕左上角的坐标。this.Left和this.Top的参考点也是屏幕 + if (Cursor == Cursors.SizeNWSE) // 倾斜拖拽 + { + // 改变窗体宽和高的代码,其宽高为鼠标屏幕位置减去窗体的Left,Top距离 + this.Width = MousePosition.X - this.Left; + this.Height = MousePosition.Y - this.Top; + } + else if (Cursor == Cursors.SizeWE) // 水平拖拽 + { + Width = MousePosition.X - this.Left; + } + else if (Cursor == Cursors.SizeNS) // 垂直拖拽 + { + Height = MousePosition.Y - this.Top; + } + } + //鼠标移动过程中,坐标时刻在改变 + //当鼠标移动时横坐标距离窗体右边缘5像素以内且纵坐标距离下边缘也在5像素以内时,要将光标变为倾斜的箭头形状 + if (e.Location.X >= this.Width - 3 && e.Location.Y > this.Height - 3) + { + this.Cursor = Cursors.SizeNWSE; // 右下角 双向对角线光标 + } + //当鼠标移动时横坐标距离窗体右边缘5像素以内时,要将光标变为双向水平箭头形状 + else if (e.Location.X >= this.Width - 3) + { + this.Cursor = Cursors.SizeWE; // 双向水平光标 + } + //当鼠标移动时纵坐标距离窗体下边缘5像素以内时,要将光标变为垂直水平箭头形状 + else if (e.Location.Y >= this.Height - 3) + { + this.Cursor = Cursors.SizeNS; // 双向垂直光标 + + } + //否则,以外的窗体区域,鼠标星座均为单向箭头(默认) + else this.Cursor = Cursors.Arrow; + } /// /// 窗体位置改变时,水印层对应改变 @@ -186,7 +235,7 @@ namespace Lskj.Main { if (ERPInfo.Instance.MainControl.WindowState == FormWindowState.Minimized) watermarkForm.Visible = false; - if (ERPInfo.Instance.MainControl.WindowState != FormWindowState.Minimized) + if (ERPInfo.Instance.MainControl.WindowState != FormWindowState.Minimized) { //watermarkForm.Size = this.ClientSize; // 设置水印窗体的大小与主窗体客户端区域相同 //watermarkForm.Location = this.PointToScreen(new Point(0, 0)); // 将水印窗体定位到主窗体的位置 @@ -195,11 +244,6 @@ namespace Lskj.Main } } - - private void FrmMain_MouseMove(object sender, MouseEventArgs e) - { - - } /// /// U盾状态改变 /// @@ -404,6 +448,14 @@ namespace Lskj.Main try { this.WindowState = this.WindowState == FormWindowState.Normal ? FormWindowState.Maximized : FormWindowState.Normal; + if (this.WindowState == FormWindowState.Maximized) + { + this.Padding = new Padding(0, 0, 0, 0); + } + else if (this.WindowState == FormWindowState.Normal) + { + this.Padding = new Padding(0, 0, 3, 3); + } this.mainPanelControlEx.State = this.WindowState; this.StartPosition = FormStartPosition.CenterScreen; this.ResetFormState(); @@ -625,35 +677,4 @@ namespace Lskj.Main public uint dwActiveProcessorMask; public uint dwNumberOfProcessors; public uint dwProcessorType; - public uint dwAllocationGranularity; - public uint dwProcessorLevel; - public uint dwProcessorRevision; - } - //定义内存的信息结构 - [StructLayout(LayoutKind.Sequential)] - public struct MEMORY_INFO - { - public uint dwLength; - public uint dwMemoryLoad; - public uint dwTotalPhys; - public uint dwAvailPhys; - public uint dwTotalPageFile; - public uint dwAvailPageFile; - public uint dwTotalVirtual; - public uint dwAvailVirtual; - } - //定义系统时间的信息结构 - [StructLayout(LayoutKind.Sequential)] - public struct SYSTEMTIME_INFO - { - public ushort wYear; - public ushort wMonth; - public ushort wDayOfWeek; - public ushort wDay; - public ushort wHour; - public ushort wMinute; - public ushort wSecond; - public ushort wMilliseconds; - } - } -} \ No newline at end of file + public uint dwAllocationGra \ No newline at end of file