VC++ Program to Demonstrate Line Drawing with Left Mouse Click with Left Mouse Button.The Color and Width Of the Line Color Should change with every new Line.


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

static int f=0;
HPEN hp;
static  int x1,y1;
switch (message)
{
case WM_LBUTTONDOWN:
hdc=GetDC(hWnd);
x1=LOWORD(lParam);
y1=HIWORD(lParam);

f++;
if(f>6)
f=1;

hp=CreatePen(0,f,RGB(rand()%255,rand()%255,rand()%255));
SelectObject(hdc,hp);
MoveToEx(hdc,x1,y1,0);
LineTo(hdc,x1+100,y1+100);

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