I hate doing this, so fiddly, everytime I have to do it I end up drawing a blank on how it's done.
The chances are that you won't be able to use a standard line drawing function, especially if your using images, maybe you need soft edges etc.
So, you need to take the new cursor position and compare it with the last cursor position, and draw each pixel between them. I do this with interpolation, basically take the differences between coordinates and find the most significant one. Like... lets say XA YA XB and YB are the coordinates, and PX PY are the pixel cords you want.
DX#=XA-XB
DY#=YA-YB
If abs(DY#)>abs(DX#)
if DY#>0.0 then SY#=1.0 else SY#=-1.0
SX#=DX#/DY#
else
if DX#>0.0 then SX#=1.0 else SX#=-1.0
SY#=DY#/DX#
endif
So that gets the differences and sets the most significant axis to 1/-1, and the other axis to a multiplier.
The trick now is to step through all the iterations, and increment the other axis by...
PX#=XA
PY#=YA
for p=0 to D
inc PX#,SX#
inc PY#,SY#
dot PX#,PY#
next p
It's pseudo code, but hopefully you understand it. You basically take the 2 points and work out which axis you can increment by 1 or -1, and the other axis increments by a value between -1 and 1. If A=10,30 and B=20,10 the difference would be 10,-20.... so stepping through 20 pixels with Y as the significant axis, increasing Y by -1 and X by 0.5 for.