日期:2014-05-17 浏览次数:21203 次
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
this.pictureBox1.Invalidate();
Graphics g = pictureBox1.CreateGraphics();
Rectangle rec = new Rectangle(5, 5, 200, 25);
g.DrawRectangle(new Pen(Color.Red), rec);
Pen pen = new Pen(Brushes.White);
g.DrawLine(pen, 0, e.Y, this.Width, e.Y);
g.DrawLine(pen, e.X, 0, e.X, this.Height);
this.pictureBox1.Update();//立即更新
Application.DoEvents();
Point p = myPanel1.PointToClient(MousePosition);//这时这个点和e.X,e.Y不一样
Console.WriteLine("Mousemove客户区位置 X=" + p.X + " Y=" + p.Y);
Console.WriteLine("Mousemove赋值前e.X=" + e.X + " lastX=" + lastX + " e.Y=" + e.Y + " lastY=" + lastY + " remain=" + remained.ToString());
}