90 lines
2.6 KiB
C#
90 lines
2.6 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.ComponentModel;
|
|||
|
using System.Data;
|
|||
|
using System.Drawing;
|
|||
|
using System.Text;
|
|||
|
using System.Linq;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using System.Windows.Forms;
|
|||
|
using DevExpress.XtraEditors;
|
|||
|
using DevExpress.XtraWaitForm;
|
|||
|
using System.Runtime.InteropServices;
|
|||
|
|
|||
|
namespace UI.Framework.Forms
|
|||
|
{
|
|||
|
public partial class LodingForm : WaitForm
|
|||
|
{
|
|||
|
public LodingForm()
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
}
|
|||
|
|
|||
|
private void LodingForm_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
this.ProgressPanel.MouseMove += MouseMove;
|
|||
|
this.ProgressPanel.MouseDown += MouseDown;
|
|||
|
this.ProgressPanel.MouseUp += MouseUp;
|
|||
|
}
|
|||
|
|
|||
|
[DllImport("user32.dll")]
|
|||
|
public static extern bool ReleaseCapture();
|
|||
|
[DllImport("user32.dll")]
|
|||
|
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
|
|||
|
|
|||
|
|
|||
|
|
|||
|
bool beginMove = false;//初始化鼠标位置
|
|||
|
int currentXPosition;
|
|||
|
int currentYPosition;
|
|||
|
|
|||
|
//获取鼠标按下时的位置
|
|||
|
private new void MouseDown(object sender, MouseEventArgs e)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (e.Button == MouseButtons.Left)
|
|||
|
{
|
|||
|
beginMove = true;
|
|||
|
currentXPosition = MousePosition.X;//鼠标的x坐标为当前窗体左上角x坐标
|
|||
|
currentYPosition = MousePosition.Y;//鼠标的y坐标为当前窗体左上角y坐标
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{ }
|
|||
|
}
|
|||
|
|
|||
|
//获取鼠标移动到的位置
|
|||
|
private new void MouseMove(object sender, MouseEventArgs e)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (beginMove)
|
|||
|
{
|
|||
|
this.Left += MousePosition.X - currentXPosition;//根据鼠标x坐标确定窗体的左边坐标x
|
|||
|
this.Top += MousePosition.Y - currentYPosition;//根据鼠标的y坐标窗体的顶部,即Y坐标
|
|||
|
currentXPosition = MousePosition.X;
|
|||
|
currentYPosition = MousePosition.Y;
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{ }
|
|||
|
}
|
|||
|
|
|||
|
//释放鼠标时的位置
|
|||
|
private new void MouseUp(object sender, MouseEventArgs e)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (e.Button == MouseButtons.Left)
|
|||
|
{
|
|||
|
currentXPosition = 0; //设置初始状态
|
|||
|
currentYPosition = 0;
|
|||
|
beginMove = false;
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{ }
|
|||
|
}
|
|||
|
}
|
|||
|
}
|