how to draw a line following my cursor

in win32,when pressing the left button and dragging,I want to draw a line conform to the track.
thanks for all replies.

You can take Tests->Render Texture Test as a sample.