Posts

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; }