Alternatively you can declare variables mouseX, mouseY, and update their values in PaintBoxOnMouseMove event, by X, Y parameters.
Or even easier by using onMouseDown (or onMouseUp) event instead of onClick. You have those cursor coordinates passed as X, Y there too.