Académique Documents
Professionnel Documents
Culture Documents
#include<windows.h>
MessageBox(0,"Application executing","Application",MB_OK);
return 0;
OUTPUT:
EXP 3 Failed!","erroe!",MB_ICONEXCLAMATION
|MB_OK);
#include<windows.h> return 0;
LPCTSTR ClsName="BasicApp"; }
LRESULT CALLBACK WndProc(HWND ShowWindow(hwnd,nCmdShow
hwnd,UINT msg,WPARAM wParam,LPARAM );
IParam); UpdateWindow(hwnd);
int WINAPI WinMain(HINSTANCE
hInstance,HINSTANCE hPrevInctance,LPSTR while(GetMessage(&Msg,NULL,
IpCmdLine,int nCmdShow) 0,0)>0)
{ {
HWND hwnd; TranslateMessage(&Msg);
WNDCLASSEX wc;
MSG Msg; DispatchMessage(&Msg);
wc.cbSize=sizeof(WNDCLASSEX); }
wc.style=0; return Msg.wParam;
wc.lpfnWndProc=WndProc; }
wc.cbClsExtra=0; LRESULT CALLBACK
wc.cbWndExtra=0; WndProc(HWND hwnd,UINT msg,WPARAM
wc.hInstance=hInstance; wParam,LPARAM lParam)
wc.hIcon=LoadIcon(NULL,IDI_AP {
PLICATION); switch(msg)
wc.hCursor=LoadCursor(NULL,ID {
C_ARROW); case WM_CLOSE:
wc.hbrBackground=(HBRUSH)(C
OLOR_WINDOW+1); DestroyWindow(hwnd);
wc.lpszMenuName=NULL; break;
wc.lpszClassName=ClsName; case WM_DESTROY:
wc.hIconSm=LoadIcon(NULL,IDI PostQuitMessage(0);
_APPLICATION); break;
if(!RegisterClassEx(&wc)) default:
{ return
MessageBox(NULL,"Window DefWindowProc(hwnd,msg,wParam,lParam);
Registration return 0;
Failed!","Error",MB_ICONEXCLAMATION | }
MB_OK); }
return 0;
}
hwnd=CreateWindowEx(WS_EX
_CLIENTEDGE,ClsName,"Simple
Window",WS_OVERLAPPEDWINDOW,CW_US
EDEFAULT,CW_USEDEFAULT,240,120,NULL,N
ULL,hInstance,NULL);
if(hwnd==NULL)
{
MessageBox(NULL,"Window
Creation
Experiment-4
RegisterClassEx(&WndClsEx);
#include<windows.h>
hWnd=CreateWindow(ClsName,Wnd
LPCTSTR ClsName="BasicApp";
Name,WS_OVERLAPPEDWINDOW,CW_USEDE
LPCTSTR WndName="EXAMPLE PROGRAM FAULT,CW_USEDEFAULT,CW_USEDEFAULT,C
FOR DRAWING SHAPES"; W_USEDEFAULT,NULL,NULL,hInstance,NULL);
WNDCLASSEX WndClsEx; {
WndClsEx.cbSize=sizeof(WNDCLASSEX TranslateMessage(&Msg);
);
DispatchMessage(&Msg);
WndClsEx.style=CS_HREDRAW|CS_VR
EDRAW; }
WndClsEx.hIconSm=LoadIcon(NULL,ID
MoveToEx(hdc,200,100,NULL);
I_APPLICATION);
LineTo(hdc,100,200); }
SetPixel(hdc,280,125,0);
MoveToEx(hdc,100,200,NULL);
LineTo(hdc,300,200);
SetPixel(hdc,280,125,0);
MoveToEx(hdc,300,200,NULL);
LineTo(hdc,200,100);
SetPixel(hdc,280,125,0);
MoveToEx(hdc,300,200,NULL);
LineTo(hdc,400,100);
SetPixel(hdc,280,125,0);
MoveToEx(hdc,400,100,NULL);
LineTo(hdc,500,200);
SetPixel(hdc,280,125,0);
MoveToEx(hdc,500,200,NULL);
LineTo(hdc,300,200);
SetPixel(hdc,280,125,0);
break;
case WM_DESTROY:
PostQuitMessage(WM_QUIT);
break;
default:
return
DefWindowProc(hWnd,message,wParam,lPar
am);
return 0;
EXPERIMENT 5
Output:
code:
#include<windows.h>
LPCTSTR ClsName="BasicApp";
MSG Msg;
HWND hWnd;
WNDCLASSEX WndClsEx;
WndClsEx.cbSize=sizeof(WNDCLASSEX);
WndClsEx.style=CS_HREDRAW | CS_VREDRAW;
WndClsEx.lpfnWndProc=(WNDPROC)WndProc;
WndClsEx.cbClsExtra=0;
WndClsEx.cbWndExtra=0;
WndClsEx.hIcon=LoadIcon(NULL,IDI_APPLICATION);
WndClsEx.hCursor=LoadCursor(NULL,IDC_ARROW);
WndClsEx.hbrBackground=(HBRUSH)(COLOR_WINDOW+1);
WndClsEx.lpszMenuName=NULL;
WndClsEx.lpszClassName=ClsName;
WndClsEx.hInstance=hInstance;
WndClsEx.hIconSm=LoadIcon(NULL,IDI_APPLICATION);
RegisterClassEx(&WndClsEx);
hWnd=CreateWindow(ClsName,WndName,WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFA
ULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);
if(!hWnd)
return 0;
ShowWindow(hWnd,SW_SHOWNORMAL);
UpdateWindow(hWnd);
while(GetMessage(&Msg,NULL,0,0))
TranslateMessage(&Msg);
DispatchMessage(&Msg);
return Msg.wParam;
HDC hdc;
PAINTSTRUCT ps;
switch(message)
case WM_PAINT:
hdc=BeginPaint(hWnd,&ps);
Rectangle(hdc,30,30,170,120);
Rectangle(hdc,200,30,340,120);
Rectangle(hdc,100,150,240,240);
break;
case WM_DESTROY:
PostQuitMessage(WM_QUIT);
break;
default:
return DefWindowProc(hWnd,message,wParam,lParam);
return 0;
Output:
EXPERIMENT 5
Output
Code
#include<windows.h>
LPCTSTR ClsName="BasicApp";
MSG Msg;
HWND hWnd;
WNDCLASSEX WndClsEx;
WndClsEx.cbSize=sizeof(WNDCLASSEX);
WndClsEx.style=CS_HREDRAW | CS_VREDRAW;
WndClsEx.lpfnWndProc=(WNDPROC)WndProc;
WndClsEx.cbClsExtra=0;
WndClsEx.cbWndExtra=0;
WndClsEx.hIcon=LoadIcon(NULL,IDI_APPLICATION);
WndClsEx.hCursor=LoadCursor(NULL,IDC_ARROW);
WndClsEx.hbrBackground=(HBRUSH)(COLOR_WINDOW+1);
WndClsEx.lpszMenuName=NULL;
WndClsEx.lpszClassName=ClsName;
WndClsEx.hInstance=hInstance;
WndClsEx.hIconSm=LoadIcon(NULL,IDI_APPLICATION);
RegisterClassEx(&WndClsEx);
hWnd=CreateWindow(ClsName,WndName,WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_U
SEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);
if(!hWnd)
return 0;
ShowWindow(hWnd,SW_SHOWNORMAL);
UpdateWindow(hWnd);
while(GetMessage(&Msg,NULL,0,0))
TranslateMessage(&Msg);
DispatchMessage(&Msg);
return Msg.wParam;
HDC hdc;
PAINTSTRUCT ps;
HBRUSH BrushGreen=CreateSolidBrush(RGB(0,125,5));
HBRUSH BrushYellow=CreateSolidBrush(RGB(250,255,5));
HBRUSH BrushRed=CreateSolidBrush(RGB(255,255,5));
POINT pt[3];
switch(message)
case WM_PAINT:
hdc=BeginPaint(hWnd,&ps);
Rectangle(hdc,300,60,400,210);
SelectObject(hdc,BrushGreen);
Polygon(hdc,pt,3);
Rectangle(hdc,200,60,300,150);
SelectObject(hdc,BrushYellow);
Polygon(hdc,pt,3);
Rectangle(hdc,300,10,500,100);
SelectObject(hdc,BrushRed);
Polygon(hdc,pt,3);
DeleteObject(BrushGreen);
DeleteObject(BrushYellow);
DeleteObject(BrushRed);
EndPaint(hWnd,&ps);
break;
case WM_DESTROY:
PostQuitMessage(WM_QUIT);
break;
default:
return DefWindowProc(hWnd,message,wParam,lParam);
return 0;
}
Experiment :--6 1
wd.cbClsExtra = 0 ; }
{ TextOut(hdc,10,50,"Key Pressed",11);
break ;
case VK_UP:
MessageBox(NULL,"Key
Pressed:","keboard",MB_OK);
break ;
case VK_SHIFT:
MessageBox(NULL,"shift Key
Pressed:","keboard",MB_OK);
break ;
case VK_CAPITAL:
MessageBox(NULL,"Capital Key
Pressed:","keboard",MB_OK);
break ;
case VK_CONTROL:
MessageBox(NULL,"Control Key
Pressed:","keboard",MB_OK);
break ;
return 0 ;
case WM_CHAR:
MessageBox(NULL,"cHARACTER Key
Pressed:","keboard",MB_OK);
break;
case WM_DESTROY:
EndPaint(hwnd,&ps);
PostQuitMessage (0) ;
return 0 ;
}
EXPERIMENT -7
#include<windows.h> return 0;
LRESULT CALLBACK }
WndProc(HWND,UINT,WPARAM,LPARAM);
// CREATING THE WINDOW
int WINAPI WinMain(HINSTANCE
hInstance,HINSTANCE hPrevInstance,PSTR hwnd=CreateWindow(szAppName,TE
szCmdLine,int iCmdShow) XT("keyboardevent"),
{ WS_OVERLAPPEDWINDOW,
PAINTSTRUCT ps;
RECT rect;
switch(message)
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
GetClientRect(hwnd,&rect);
DrawText(hdc,TEXT("HELLO
WINDOWS 98"),-
1,&rect,DT_SINGLELINE|DT_CENTER|DT_VCE
NTER);
EndPaint(hwnd,&ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
return
DefWindowProc(hwnd,message,wparam,lpar
am);