title: Draw new line every time mouse is moved in c++ builder
body: <p>I have a code I want to load every time I move my mouse cursor; it draws line to direction of mouse and beyond, and every time it the line gets to certain x coordinate, the line reflects. The problem is that now the program only draws line when I click on the PaintBox.
  Here is my code so far:</p>
  
  <pre><code>void __fastcall TForm2::PaintBox1Click(TObject *Sender)
  {
     Form2-&gt;Refresh();
     TPoint P;
     ::GetCursorPos( &amp;P );
     P = ScreenToClient( P );
     int XX;
     int YY;
     if (P.x&lt;240) 
     {
        XX=15;
        YY= ((445-P.y)*(XX-P.x)/(240-P.x)+P.y);
     } 
     else if(P.x==240)
     {
        XX=240;YY=-5; 
     }
     else
     { 
        XX=465;
        YY= ((445-P.y)*(XX-P.x)/(240-P.x)+P.y);   
     }
     int delta=2*(445-YY);
  
     this-&gt;Canvas-&gt;MoveTo(240, 445);
     this-&gt;Canvas-&gt;LineTo(XX,YY);
     while(0&lt;YY&amp;&amp;YY&lt;480&amp;&amp;YY!=445)
     {
        XX=abs(480-XX);
        YY-=delta;
        this-&gt;Canvas-&gt;LineTo(XX,YY);
     }
  }
  </code></pre>