0

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.

I submit the image of program. Same things are written with mouse and tablet pen.

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.

So I have to make program recognize the MouseUp event as soon as pen is separated form the tablet like mouse does.

Is there any way to recognize mouse up happened except MouseClick->false or MouseUp event? I already tried to use switch the variable in MouseDown and MouseUp events but it doesn't work.

'''

void __fastcall TForm1::Image1MouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y)  
{
    Image1->Picture->Bitmap->Canvas->MoveTo(X,Y);
    pt_x=X;
    pt_y=Y;
    
    if (Button == mbLeft){
        if(type==0){               //penmode 
            Image1->Picture->Bitmap->Canvas->Pen->Color = ColorDialog1->Color;
            PenColor = ColorDialog1->Color;
        }
        else if(type==1)         //erasermode
        {
            Image1->Picture->Bitmap->Canvas->Pen->Color = clWhite;
            PenColor = clWhite;
        }
    }

    else if (Button == mbRight)     //eraser mode for right click
    {
        Image1->Picture->Bitmap->Canvas->Pen->Color = clWhite;
        PenColor = clWhite;
    }

    Image1->Picture->Bitmap->Canvas->Pen->Width = ScrollBar1->Position;
    PenWidth = ScrollBar1->Position;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Image1MouseMove(TObject *Sender, TShiftState Shift, int X, int Y)
{
    if(Shift.Contains(ssLeft))
    {
        Image1->Picture->Bitmap->Canvas->MoveTo(pt_x,pt_y);
        Image1->Picture->Bitmap->Canvas->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;
}

//---------------------------------------------------------------------------

'''

sieun
  • 39
  • 3
  • This question is no different than your [previous question](https://stackoverflow.com/questions/70758513/). So why are you asking this again? Any relevant updates (ie, code changes you tried) should have been posted as edits to your previous question. – Remy Lebeau Jan 24 '22 at 18:06
  • @ Remy Lebeau I've tried all things you told before (using mbleft, and Shift component). Also instead of using mouse location directly, this code update pt_x and pt_y variables. But it doesn't work at all. These were all thing I can try. Because I'm a beginner, I thought it is quite different from the previous one. If not, plz tell me what should I do more. – sieun Jan 25 '22 at 01:39

0 Answers0