Posts

Showing posts from December, 2015

PHP Programs for MCA

Practical Slips Class Php Lecture Php

Write a VC++ Window Program to Display the Characters entered by User from the Keyboard and type five to six Lines also take care of backspace is work.

Add #define ID_EDIT 1 LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; static HWND hwndEdit; switch (message) { case WM_CREATE: hwndEdit=CreateWindow(TEXT("edit"),NULL,WS_CHILD|WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL|WS_BORDER|ES_LEFT|ES_MULTILINE|ES_AUTOHSCROLL|ES_AUTOVSCROLL,0,0,0,0,hWnd,(HMENU)ID_EDIT,((LPCREATESTRUCT)lParam)->hInstance,NULL); break; case WM_SETFOCUS: SetFocus(hwndEdit); break; case WM_SIZE: MoveWindow(hwndEdit,0,0,LOWORD(lParam),HIWORD(lParam),TRUE); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam);    }    return 0; }

Write a VC++ Window program to display user defined push button and radio button on client area.As User Click the buttons appropriate message is displayed.

Add #define IDC_MAIN_BUTTON 101 #define IDC_MAIN_RBUTTON 102 LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; HWND button,but; switch (message) { case WM_CREATE: button=CreateWindowEx(0,"Button","RadioButton",WS_VISIBLE|WS_CHILD|BS_AUTORADIOBUTTON,250,220,100,24,hWnd,(HMENU)IDC_MAIN_RBUTTON,0,0); but=CreateWindowEx(0,"Button","PushButton",WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON,50,220,100,24,hWnd,(HMENU)IDC_MAIN_BUTTON,0,0); break; case WM_COMMAND: hdc=GetDC(hWnd); switch(LOWORD(wParam)) { case IDC_MAIN_RBUTTON: TextOut(hdc,50,50,"Radio Button Pressed.....",30); break; case IDC_MAIN_BUTTON: TextOut(hdc,50,70,"Push Button is Pressed....",30); break; } break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); ...
Write a VC++ Program to display line by pressing ctrl+F1 and Circle by Alter+F2. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; switch (message) { case WM_SYSKEYDOWN: hdc=GetDC(hWnd); if(GetKeyState(VK_MENU)<0 && GetKeyState(VK_F2)<0) { Ellipse(hdc,50,50,200,200); } break; case WM_KEYDOWN: hdc=GetDC(hWnd); if(GetKeyState(VK_CONTROL)<0 &&  GetKeyState(VK_F1)<0) { MoveToEx(hdc,100,100,0); LineTo(hdc,400,400); } break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam);    }    return 0; }
Write a VC++ Program that Displays a small Rectangle,clicking inside Rectangle color should be change and Clicking out side of the Rectangle Should erase. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; HBRUSH hbr; static int x=200,y=200,x1,y1; static POINT pt; static RECT r1; switch (message) { case WM_PAINT: hdc=BeginPaint(hWnd,&ps); x1=x+100; y1=y+100; Rectangle(hdc,x,y,x1,y1); RECT rt; GetClientRect(hWnd,&rt); EndPaint(hWnd,&ps); break; case WM_LBUTTONDOWN: hdc=GetDC(hWnd); pt.x=LOWORD(lParam); pt.y=HIWORD(lParam); r1.left=x; r1.top=y; r1.right=x1; r1.bottom=y1; hbr=CreateSolidBrush(RGB(rand()%255,rand()%255,rand()%255)); SelectObject(hdc,hbr); if(PtInRect(&r1,pt)) { FillRect(hdc,&r1,hbr); } else { InvalidateRect(hWnd,&r1,true); } break; case WM_DESTROY: PostQu...
Write a VC++ Program to Display String with Diffrent Width on Each Mouse Click.The String Should be Displayed at the Point where User Click. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; HFONT hf; int x1,y1; switch (message) { case WM_LBUTTONDOWN: hdc=GetDC(hWnd); x1=LOWORD(lParam); y1=HIWORD(lParam); hf=CreateFont(rand()%50,0,0,0,0,700,0,0,0,0,0,0,0,"Times New Roman"); SelectObject(hdc,hf); SetTextColor(hdc,RGB(rand()%255,rand()%255,rand()%255)); TextOut(hdc,x1,y1,"GHRIBM",6); return 0; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam);    }    return 0; }
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; }
Write a Window program to display random rectangle. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; static x,y,x1,y1; switch (message) { case WM_CREATE: SetTimer(hWnd,1,1000,NULL); return 0; case WM_TIMER: hdc=GetDC(hWnd); x=rand()%500; y=rand()%500; x1=x+100; y1=y+100; Rectangle(hdc,x,y,x1,y1); return 0; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam);    }    return 0; }
Write a VC++ Program to change Background Color of the Window after every 2 Seconds.And at each Mouse Click the fill Pattern should Change. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; RECT rect; HBRUSH hbr; static int i=0; switch (message) { case WM_CREATE: SetTimer(hWnd,1,2000,NULL); return 0; case WM_TIMER: hdc=GetDC(hWnd); GetClientRect(hWnd,&rect); if(i==0) hbr=CreateSolidBrush(RGB(rand()%255,rand()%255,rand()%255)); else hbr=CreateHatchBrush(i,RGB(rand()%255,rand()%255,rand()%255)); FillRect(hdc,&rect,hbr); return 0; case WM_LBUTTONDOWN: if(i<5) { i++; } else { i=0; } return 0; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam);    }    return 0; }
Write a VC++ Program to Demonstrate MetaFiles.  LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc,hdcMeta; static HMETAFILE hmf; static int cxClient,cyClient; HBRUSH hBrush; int x,y; switch (message) { case WM_CREATE: hdcMeta=CreateMetaFile(NULL); hBrush=CreateSolidBrush(RGB(0,0,255)); Rectangle(hdcMeta,0,0,100,100); MoveToEx(hdcMeta,0,0,NULL); LineTo(hdcMeta,100,100); MoveToEx(hdcMeta,0,100,NULL); LineTo(hdcMeta,100,0); SelectObject(hdcMeta,hBrush); Ellipse(hdcMeta,20,20,80,80); hmf=CloseMetaFile(hdcMeta); DeleteObject(hBrush); return 0; case WM_SIZE: cxClient=LOWORD(lParam); cyClient=HIWORD(lParam); return 0; case WM_PAINT: hdc=BeginPaint(hWnd,&ps); SetMapMode(hdc,MM_ANISOTROPIC); SetWindowExtEx(hdc,1000,1000,NULL); SetViewportExtEx(hdc,cxClient,cyClient,NULL); for(x=0;x<10;x++) { for(y=0;y<10;y++) ...
Write a VC++ Program to Draw Following Shapes on Client area when the user presses the : C-Circle,R-Rectangle,E-Ellipse,L-Line,G-Round Rectangle. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; static char res; static int x,y; switch (message) { case WM_CHAR: hdc=GetDC(hWnd); x=rand()%500; y=rand()%500; sprintf(&res,"%c",wParam); if(res=='c' || res=='C') { Ellipse(hdc,x,y,x+200,y+200); } else if(res=='r' || res=='R') { Rectangle(hdc,x,y,x+150,y+150); } else if(res=='e' || res=='E') { Ellipse(hdc,x,y,x+200,y+100); } else if(res=='l' || res=='L') { MoveToEx(hdc,x,y,0); LineTo(hdc,x+100,y+100); } else { RoundRect(hdc,x,y,x+200,y+200,50,50); } break; case WM_DESTROY: PostQuitMessage(0); break; default: return ...
Write a VC++ Program to display following shapes in successive mouse clicks; Line,Rectangle,Circle,ellipse,Erase. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; RECT r; static int count=0,i; static int x,y,x1,y1; switch (message) { case WM_LBUTTONDOWN: count++; hdc=GetDC(hWnd); x=LOWORD(lParam); y=HIWORD(lParam); x1=x+100; y1=y+100; GetClientRect(hWnd,&r); if(count==1) { MoveToEx(hdc,x,y,0); LineTo(hdc,x1,y1); } else if(count==2) { Rectangle(hdc,x,y,x1,y1); } else if(count==3) { Ellipse(hdc,x,y,x1,y1); } else if(count==4) { Ellipse(hdc,x,y,x1+100,y1); } else if(count==5) { InvalidateRect(hWnd,&r,true); count=0; } break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam);    }    return...
Write a VC++ Program to draw Lines from Fixed Point to Current Mouse Position as Mouse Moved Around the Point.Each time you press the mouse drawing should begin from the Point you Click. (FreeHand Drawing) LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; static int x,y,i; static int x1,y1,f=0; switch (message) { case WM_LBUTTONDOWN: if(f==0) { hdc=GetDC(hWnd); x=LOWORD(lParam); y=HIWORD(lParam); f=1; } break; case WM_MOUSEMOVE: if(f==1) { hdc=GetDC(hWnd); x1=LOWORD(lParam); y1=HIWORD(lParam); } MoveToEx(hdc,x,y,0); LineTo(hdc,x1,y1); x=x1; y=y1; break; case WM_LBUTTONUP: f=0; break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam);    }    return 0; }
Write VC++ a Program to Draw Rectangle Intersected with Another Rectangle.the Intersected Part Should have Diffrent Color,also show the Union of Rectangle With Diffrent Color. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; RECT Rect1,Rect2,iRect,uRect; HBRUSH Rect1Hbr,Rect2Hbr,iHbr,uHbr; switch (message) { case WM_CREATE: return 0; case WM_PAINT: hdc=BeginPaint(hWnd,&ps); Rect1Hbr=CreateSolidBrush(RGB(0,0,255)); Rect2Hbr=CreateSolidBrush(RGB(255,255,0)); iHbr=CreateSolidBrush(RGB(0,255,0)); uHbr=CreateSolidBrush(RGB(255,0,0)); SetRect(&Rect1,50,50,250,250); SetRect(&Rect2,150,150,350,350); UnionRect(&uRect,&Rect1,&Rect2); FillRect(hdc,&uRect,uHbr); FillRect(hdc,&Rect1,Rect1Hbr); FillRect(hdc,&Rect2,Rect2Hbr); IntersectRect(&iRect,&Rect1,&Rect2); FillRect(hdc,&iRect,iHbr); break; ca...
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; }
Write a VC++ Program to draw a Rectangle and when User Clicks Inside the Rectangle should be Display the two Cross Line as Diagonal of the Rectangle. and it should be erased when clicked Outside. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; static int x=220,y=180,x1,y1; static POINT pt; static RECT r1; switch (message) { case WM_PAINT: hdc=BeginPaint(hWnd,&ps); x1=x+100; y1=y+100; Rectangle(hdc,x,y,x1,y1); RECT rt; GetClientRect(hWnd,&rt); EndPaint(hWnd,&ps); break; case WM_LBUTTONDOWN: hdc=GetDC(hWnd); pt.x=LOWORD(lParam); pt.y=HIWORD(lParam); r1.left=x; r1.top=y; r1.right=x1; r1.bottom=y1; if(PtInRect(&r1,pt)) { MoveToEx(hdc,x,y,0); LineTo(hdc,x1,y1); MoveToEx(hdc,x,y1,0); LineTo(hdc,x1,y); } else { InvalidateRect(hWnd,&r1,true); } break; ca...
Write VC++ Program that Home,Page Up,Page Down,End & all Arrow Keys as user presses these keys.Program should display appropriate message in the client window. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; switch (message) { case WM_KEYDOWN: hdc=GetDC(hWnd); switch(wParam) { case VK_HOME: TextOut(hdc,50,50,"HOME KEY",8); break; case VK_END: TextOut(hdc,50,100,"END KEY",7); break; case VK_PRIOR: TextOut(hdc,50,150,"PAGE UP KEY",11); break; case VK_NEXT: TextOut(hdc,50,200,"PAGE DOWN KEY",13); break; case VK_UP: TextOut(hdc,50,250,"UP ARROW KEY",12); break; case VK_DOWN: TextOut(hdc,50,300,"DOWN ARROW KEY",14); break; case VK_LEFT: TextOut(hdc,50,350,"LEFT ARROW DOWN",14); break; case VK_RIGHT: TextOut(...
VC++ Program to display three Sinewaves on client area by clicking mouse left button. Add #define TWOPI 2*3.14159 #include"math.h" LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; static int x,y; POINT pt[1000]; int i; static int f=0; switch (message)  { case WM_SIZE: x=LOWORD(lParam); y=HIWORD(lParam); return 0; case WM_LBUTTONDOWN: hdc=GetDC(hWnd); if(f==0) { MoveToEx(hdc,0,y/4,NULL); LineTo(hdc,x,y/4); for(i=0;i<1000;i++) { pt[i].x=i*x/1000; pt[i].y=(int)(y/4*(1-sin(TWOPI*i/1000))); } Polyline(hdc,pt,1000); f=1; } else if(f==1) { MoveToEx(hdc,0,y/2,NULL); LineTo(hdc,x,y/2); for(i=0;i<1000;i++) { pt[i].x=i*x/1000; pt[i].y=(int)(y/4*(2-sin(TWOPI*i/1000))); } Polyline(hdc,pt,1000); f=2; } else { ...
Write a Program to Draw Sinewave Add #define TWOPI 2*3.14159 #include"math.h" LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; static int x,y; POINT pt[1000]; int i; switch (message)  { case WM_SIZE: x=LOWORD(lParam);//width y=HIWORD(lParam);//height return 0; case WM_PAINT: hdc=BeginPaint(hWnd,&ps); MoveToEx(hdc,0,y/2,NULL); LineTo(hdc,x,y/2); for(i=0;i<1000;i++) { pt[i].x=i*x/1000; pt[i].y=(int)(y/2*(1-sin(TWOPI*i/1000))); } Polyline(hdc,pt,1000); return 0; break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam);    }    return 0; }
Write a Window Program to Display the Character Enter By user from the Keyboard.[consider only alphabets and numbers only]  Add #include"stdio.h" LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; char res[20]; static int i,j; switch (message) { case WM_CHAR: hdc=GetDC(hWnd); sprintf(res,"%c",wParam); TextOut(hdc,i,j,res,strlen(res)); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam);    }    return 0; }
Write a Window Program to Move a Ball Horizontally inside the Client area using timer.At each time lapse the ball should should move left of the Window and when It Touches Left Boundary of the Window it Should go to,the right onf the window and so on. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; HBRUSH br; static int l,b,r,t,f; HRGN hrgn; RECT rect; switch (message) { case WM_CREATE: t=20; b=20; r=60; l=60; SetTimer(hWnd,1,100,NULL); return 0; case WM_TIMER: GetClientRect(hWnd,&rect); InvalidateRect(hWnd,&rect,true); return 0; case WM_PAINT: hdc=BeginPaint(hWnd,&ps); hdc=GetDC(hWnd); GetClientRect(hWnd,&rect); br=CreateSolidBrush(220); if(b<rect.right-40 && f==0) { b=b+20; r=r+20; } else { f=1; b=b-20; r=r-20; if(b<rect.left) f=0; } hrgn=CreateEllipticRgn(b,...
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; }
Write a Window Program to Create Various Brushes and Change the Background Color to Brushesh on Left Mouse Click. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; RECT rect; HBRUSH hbr; HBITMAP hBitmap; static int f=0; static BYTE bits[]={0*51,0*77,0*10,0*00, 0*57,0*77,0*50,0*00, 0*13,0*77,0*50,0*00, 0*51,0*11,0*10,0*00}; hBitmap=CreateBitmap(20,5,1,1,bits); switch (message) { case WM_LBUTTONDOWN: hdc=GetDC(hWnd); f++; if(f>8) f=1; GetClientRect(hWnd,&rect); switch(f) { case 1: hbr=CreateSolidBrush(RGB(rand()%255,rand()%255,rand()%255)); break; case 2: hbr=CreateHatchBrush(HS_CROSS,RGB(rand()%255,rand()%255,rand()%255)); break; case 3: hbr=CreateHatchBrush(HS_BDIAGONAL,RGB(rand()%255,rand()%255,rand()%255)); break; case 4: hbr=CreateHatchBrush(HS_DIAGCROSS,RGB(rand()%255,rand()%255,rand...
Write a VC++   Window Program to Create Filled Rectangle and Circle on Alternate Left Click.New Figure Should Not Erase the Previous One.If User Clicks Inside any Figure a Mistake Box Should Display LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; HRGN hrgn; HBRUSH hbr; static int x1,y1,f; static POINT pt; static RECT r1; static int res[50][2]; static int i=1,j=1,k=1; switch (message) { case WM_LBUTTONDOWN: hdc=GetDC(hWnd); x1=LOWORD(lParam); y1=HIWORD(lParam); res[i][1]=x1; res[i][2]=y1; i++; hbr=CreateSolidBrush(RGB(rand()%255,rand()%255,rand()%255)); SelectObject(hdc,hbr); switch(f) { case 0:SetRect(&r1,x1,y1,x1+100,y1+100); FillRect(hdc,&r1,hbr); f++; break; case 1:hrgn=CreateEllipticRgn(x1,y1,x1+100,y1+100); FillRgn(hdc,hrgn,hbr); f=0; break; } break; case WM_RBUTTONDOWN: ...
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,20...
VC++ Program that Displays a small Rectangle with every Left Mouse button.Double Clicking on existing rectangle should erase the rectangle. Add 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 n,i; static RECT count[100]; static int x,y,x1,y1; switch (message)  { case WM_LBUTTONDOWN: hdc=GetDC(hWnd); x=LOWORD(lParam); y=HIWORD(lParam); x1=x+100; y1=y+100; Rectangle(hdc,x,y,x1,y1); count[n].left=x; count[n].top=y; count[n].right=x1; count[n].bottom=y1; n++; break; case WM_LBUTTONDBLCLK: x=LOWORD(lParam); y=HIWORD(lParam); for(i=0;i<n;i++) { if(x>count[i].left && x<count[i].right && y<count[i].bottom && y>count[i].top) { InvalidateRect(hWnd,&count[i],...
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; }