How do I determine if a mouse button is pressed and moving over a form?
Catch the form’s MouseMove event which is called when the mouse moves over the form. To determine if a button is pressed during the move, check the event arg’s Button property. The code below draw’s a line on the form as the mouse moves over it. The line is red when the left button is pressed, white when the right button is pressed and blue when no button is pressed. private Point point = new Point( -1, -1 ); private void InitializeComponent() { // … MouseMove += new MouseEventHandler( Form1_MouseMove ); // … } private void Form1_MouseMove( object sender, MouseEventArgs e ) { if ( point.X == -1 ) point = new Point( e.X, e.Y ); Color color = BackColor; if ( e.Button == MouseButtons.Left ) color = Color.Red; else if ( e.Button == MouseButtons.Right ) color = Color.White; else if ( e.Button == MouseButtons.None ) color = Color.Blue; Point point2 = new Point( e.X,e.Y ); using ( Graphics g = Graphics.FromHwnd( Handle ) ) { using ( Pen pen = new Pen( color, 1 ) ) g.DrawLine( pen, point,