注塑喷涂
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

79 lines
2.4 KiB

using DBUtility;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FiveScreen
{
public partial class FrmCenter : Form
{
bool isMouseDown = false; // 窗体是否移动
Point currentFormLocation = new Point(); // 当前窗体位置
Point currentMouseOffset = new Point(); // 当前鼠标的按下位置
public FrmCenter()
{
InitializeComponent();
// this.WindowState = FormWindowState.Normal;
tableLayoutPanel1.MouseDown += FrmCenter_MouseDown;
tableLayoutPanel1.MouseMove += FrmCenter_MouseMove;
tableLayoutPanel1.MouseUp += FrmCenter_MouseUp;
this.WindowState = FormWindowState.Maximized;
}
private void tableLayoutPanel1_DoubleClick(object sender, EventArgs e)
{
//Application.Exit();
if (this.WindowState == FormWindowState.Maximized)
{
this.WindowState = FormWindowState.Normal;
}
else
{
this.WindowState = FormWindowState.Maximized;
}
}
private void panel1_DoubleClick(object sender, EventArgs e)
{
}
private void FrmCenter_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
isMouseDown = true;
currentFormLocation = this.Location;
currentMouseOffset = Control.MousePosition;
}
}
private void FrmCenter_MouseMove(object sender, MouseEventArgs e)
{
int rangeX = 0, rangeY = 0; // 计算当前鼠标光标的位移,让窗体进行相同大小的位移
if (isMouseDown)
{
Point pt = Control.MousePosition;
rangeX = currentMouseOffset.X - pt.X;
rangeY = currentMouseOffset.Y - pt.Y;
this.Location = new Point(currentFormLocation.X - rangeX, currentFormLocation.Y - rangeY);
}
}
private void FrmCenter_MouseUp(object sender, MouseEventArgs e)
{
isMouseDown = false; // 停止移动
}
}
}