Write a VC++ Program to Draw Line Between the Point where you click.Each time you Click end Point should be the Starting Point of Line.
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
static int x,y,x1,y1;
static bool flag=true;
switch (message)
{
case WM_LBUTTONDOWN:
hdc=GetDC(hWnd);
x1=LOWORD(lParam);
y1=HIWORD(lParam);
if(flag==true)
{
flag=false;
}
else
{
MoveToEx(hdc,x,y,0);
LineTo(hdc,x1,y1);
}
x=x1;
y=y1;
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
Comments
Post a Comment