Tek-Tips isn't a debugging or coding service. So you're going to have to do some work!
Where do you think you are erasing the previous line in your code?
Your code here draws the new line:
MoveToEx(Canvas.Handle, X, 10, nil);
LineTo(Canvas.Handle, X, Y - 10);
What you need to do is have...