Write a Window Program to Create a Window Object.Drag the Left Mouse Button & Display Rectangle for Which dragged Line is a Diagonal.Also Demonstrate Mouse Capturing.


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:
if(f==0)
{
x=LOWORD(lParam);
y=HIWORD(lParam);
f=1;
}
break;

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

case WM_LBUTTONUP:
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