VC++ Program to display size of window and No of Left Clicks and right Clicks and No. of right and Left Double Clicks.



Include #include"stdio.h"
wcex.style= CS_HREDRAW | CS_VREDRAW |CS_DBLCLKS;

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

static int x,y,lb=0,rb=0,dlb=0,drb=0;
char buf[50];
static RECT r;

switch (message)
{
case WM_SIZE:
x=LOWORD(lParam);
y=HIWORD(lParam);
InvalidateRect(hWnd,&r,true);
break;
case WM_PAINT:
hdc=BeginPaint(hWnd,&ps);
TextOut(hdc,50,350,buf,sprintf(buf,"Height of Window:%d",y));
TextOut(hdc,50,300,buf,sprintf(buf,"Width of Window:%d",x));
TextOut(hdc,50,50,buf,sprintf(buf,"No of left Click:%d",lb));
TextOut(hdc,50,100,buf,sprintf(buf,"No of Right Click:%d",rb));
TextOut(hdc,50,150,buf,sprintf(buf,"No of Left Dbl Click:%d",dlb));
TextOut(hdc,50,200,buf,sprintf(buf,"No of Right Dbl Click:%d",drb));

GetClientRect(hWnd,&r);
EndPaint(hWnd,&ps);
break;

case WM_LBUTTONDOWN:
hdc=GetDC(hWnd);
lb++;
InvalidateRect(hWnd,&r,true);
break;

case WM_RBUTTONDOWN:
hdc=GetDC(hWnd);
rb++;
InvalidateRect(hWnd,&r,true);
break;
case WM_LBUTTONDBLCLK:

hdc=GetDC(hWnd);
lb--;
dlb++;
InvalidateRect(hWnd,&r,true);
break;

case WM_RBUTTONDBLCLK:
hdc=GetDC(hWnd);
rb--;
drb++;
InvalidateRect(hWnd,&r,true);
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