日期:2014-05-17 浏览次数:20709 次
public partial class Form2 : Form
{
Point Form2_MouseMove;
public Form2()
{
InitializeComponent();
}
private void Form2_Paint(object sender, PaintEventArgs e)
{
Graphics dc = e.Graphics;
Pen blue = new Pen(Color.Blue, 3);
dc.DrawRectangle(blue, Form2_MouseMove.X, Form2_MouseMove.Y, 50, 50);
}
private void Form2_MouseMove_1(object sender, MouseEventArgs e)
{
Form2_MouseMove.X = e.X;
Form2_MouseMove.Y = e.Y;
this.Text = string.Format("鼠标位置:({0},{1})", Form2_MouseMove.X, Form2_MouseMove.Y);
this.Invalidate();
}
public partial class Form1 : Form
{
Point pt;
public Form1()
{
InitializeComponent();
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
Graphics dc = e.Graphics;
Pen blue = new Pen(Color.Blue, 3);
dc.DrawRectangle(blue, pt.X, pt.Y, 50, 50);
}
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
pt.X = e.X;
pt.Y = e.Y;
this.Text = string.Format("鼠标位置:({0},{1})", pt.X, pt.Y);