I am quite new with Visual C++. I know C++ pretty good. I am starting to write small programs in VC++ , at the moment Win32 application to draw lines with mouse movements.

Ok..now the problem..

I wrote a small program that draws lines on mousedown and mouseup. ie. It captures the mouse co-ordinates in WM_LBUTTONDOWN , saves it to two variables, and in WM_LBUTTONDOWN captures the mouse co-ordinates and draw a line btn these two points. But it always draw the line from top left of the window to the current point. Can u please help me ? Here is my code.

case WM_LBUTTONDOWN:
POINTS p;
p=MAKEPOINTS(lParam);
xPos=p.x;
yPos=p.y;
break;
case WM_LBUTTONUP:
p=MAKEPOINTS(lParam);
MoveToEx(GetDC(hWnd),p.x,p.y,NULL);
LineTo(GetDC(hWnd),p.x+10,p.y+10);
break;

xPos and yPos I declared as global variables. where is my mistake?