title: free drawing canvas with mouse
body: <p>I'm making a kind of paintbrush program with a c++ builder.
  The program works well with mouse, but there's a recognition problem when I draw with a tablet
  especially writing letters.</p>
  <p>I submit the image of program.
  <a href="https://i.stack.imgur.com/u8Hl9.png" rel="nofollow noreferrer">Same things are written with mouse and tablet pen.</a></p>
  <p>I think I found the reason of the problem.
  When I quickly repeat MouseDown and MouseUp with the tablet pen, the program recognizes it mouse move so short line is drawn instead of two dots.</p>
  <p>So I have to make program recognize the MouseUp event as soon as pen is separated form the tablet like mouse does.</p>
  <p>Is there any way to recognize mouse up happened except MouseClick-&gt;false or MouseUp event? I already tried to use switch the variable in MouseDown and MouseUp events but it doesn't work.</p>
  <p>'''</p>
  <pre><code>void __fastcall TForm1::Image1MouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y)  
  {
      Image1-&gt;Picture-&gt;Bitmap-&gt;Canvas-&gt;MoveTo(X,Y);
      pt_x=X;
      pt_y=Y;
      
      if (Button == mbLeft){
          if(type==0){               //penmode 
              Image1-&gt;Picture-&gt;Bitmap-&gt;Canvas-&gt;Pen-&gt;Color = ColorDialog1-&gt;Color;
              PenColor = ColorDialog1-&gt;Color;
          }
          else if(type==1)         //erasermode
          {
              Image1-&gt;Picture-&gt;Bitmap-&gt;Canvas-&gt;Pen-&gt;Color = clWhite;
              PenColor = clWhite;
          }
      }
  
      else if (Button == mbRight)     //eraser mode for right click
      {
          Image1-&gt;Picture-&gt;Bitmap-&gt;Canvas-&gt;Pen-&gt;Color = clWhite;
          PenColor = clWhite;
      }
  
      Image1-&gt;Picture-&gt;Bitmap-&gt;Canvas-&gt;Pen-&gt;Width = ScrollBar1-&gt;Position;
      PenWidth = ScrollBar1-&gt;Position;
  }
  //---------------------------------------------------------------------------
  
  void __fastcall TForm1::Image1MouseMove(TObject *Sender, TShiftState Shift, int X, int Y)
  {
      if(Shift.Contains(ssLeft))
      {
          Image1-&gt;Picture-&gt;Bitmap-&gt;Canvas-&gt;MoveTo(pt_x,pt_y);
          Image1-&gt;Picture-&gt;Bitmap-&gt;Canvas-&gt;LineTo(X,Y);
          pt_x=X;
          pt_y=Y;
      }
  }
  
  //---------------------------------------------------------------------------
  
  void __fastcall TForm1::Image1MouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y)
  {
      MouseClick=false;
  }
  
  //---------------------------------------------------------------------------
  </code></pre>
  <p>'''</p>