111,120
社区成员
发帖
与我相关
我的任务
分享 public partial class Form1 : Form
{
Point oldpoint;
Point newpoint;
bool startmove = false;
int count = 0;
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
count++;
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (startmove)
{
float a = (e.X - oldpoint.X) * 10 / count;
if(a>500)
{
MessageBox.Show("到达500的位移速度!");
}
}
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
startmove = true;
count = 1;
oldpoint = e.Location;
this.timer1.Start();
}
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
startmove = false;
newpoint = e.Location;
this.timer1.Stop();
float a = (newpoint.X - oldpoint.X)*10 / count;
this.label1.Text = a.ToString();
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication219
{
public partial class Form1 : Form
{
Point Old = new Point(-1, -1);
public Form1()
{
InitializeComponent();
this.MouseMove += new MouseEventHandler(Form1_MouseMove);
}
void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
if (Old.X != -1 && e.X - Old.X > 80)
MessageBox.Show("!");
Old = e.Location;
}
else
Old = new Point(-1, -1);
}
}
}