Write a VC++ Program that displays a Line when Mouse is Dragged from one point to another.




LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;

static int x,y,x1,y1,f=0;
switch (message)
{
case WM_LBUTTONDOWN:
x=LOWORD(lParam);
y=HIWORD(lParam);
break;

case WM_LBUTTONUP:
f=1;
x1=LOWORD(lParam);
y1=HIWORD(lParam);
if(f==1)
{
hdc=GetDC(hWnd);
MoveToEx(hdc,x,y,0);
LineTo(hdc,x1,y1);
f=0;
}

break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}

Comments

Popular posts from this blog

Uploading Image to Sql Server Image Datatype in asp.net using fileupload Control

Get Running Sum of Query SQL Query