Windows Programming: Design Problem
Windows Programming: Design Problem
Windows Programming: Design Problem
WINDOWS PROGRAMMING
DESIGN PROBLEM
SUBMITTED TO:
#include <windows.h>
enum{ID_SUM,ID_SUM_1STLINE,ID_SUM_2NDLINE,ID_SUM_3RDLIN
E,ID_SUM_4THLINE,ID_SUM_5THLINE,ID_SUM_6THLINE,ID_SUM_7
THLINE,ID_SUM_8THLINE,ID_QUIT,ID_INFO,ID_CHECK,ID_CHECK
_STATIC,ID_CHECK_NAME};
}
hwnd = CreateWindow
(szAppName,TEXT("ANJANI"),WS_OVERLAPPEDWINDOW|
WS_THICKFRAME|WS_MAXIMIZE|
WS_MAXIMIZEBOX,0,0,1300,700,NULL,NULL, hInstance, NULL)
;
ShowWindow (hwnd, iCmdShow);
UpdateWindow (hwnd) ;
MessageBox(hwnd,TEXT("VERSION 1.0 BETA"),TEXT("KUNWAR'S
COMPANY"),MB_OK);
while (GetMessage (&msg, NULL, NULL, NULL))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
case WM_CREATE:
menu=CreateMenu();
pop=CreatePopupMenu();
popu=CreatePopupMenu();
AppendMenu(menu,MF_POPUP,
(UINT_PTR)pop,TEXT("SUM"));
AppendMenu(pop,MF_STRING,ID_SUM_1STLINE,TEXT("Line
1"));
AppendMenu(pop,MF_STRING,ID_SUM_2NDLINE,TEXT("Line
2"));
AppendMenu(pop,MF_STRING,ID_SUM_3RDLINE,TEXT("Line
3"));
AppendMenu(pop,MF_STRING,ID_SUM_4THLINE,TEXT("Line
4"));
AppendMenu(pop,MF_STRING,ID_SUM_5THLINE,TEXT("Line
5"));
AppendMenu(pop,MF_STRING,ID_SUM_6THLINE,TEXT("Line
6"));
AppendMenu(pop,MF_STRING,ID_SUM_7THLINE,TEXT("Line
7"));
AppendMenu(pop,MF_STRING,ID_SUM_8THLINE,TEXT("Line
8"));
AppendMenu(menu,MF_POPUP,
(UINT_PTR)popu,TEXT("CHECK"));
AppendMenu(popu,MF_STRING,ID_CHECK_NAME,TEXT("NAME"));
AppendMenu(popu,MF_STRING,ID_CHECK_STATIC,TEXT("STATIC"
));
AppendMenu(menu,MF_STRING,ID_INFO,TEXT("INFO"));
AppendMenu(menu,MF_STRING,ID_QUIT,TEXT("QUIT"));
SetMenu(hwnd,menu);
hwnd=CreateWindow(TEXT("BUTTON"),TEXT("CLICK
ME"),WS_CHILD|WS_VISIBLE,590,600,70,30,hwnd,NULL,
(HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE),NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
break;
case WM_COMMAND:
switch(wParam)
{
case ID_INFO:
if(hChild==NULL)
{
// i=GetWindowLong(h,GWL_HINSTANCE);
hChild=CreateWindow(TEXT("Childclass"),TEXT("THANKS
GIVING"), WS_CHILD | WS_BORDER |
WS_CAPTION,600,400,280,150,hwnd,NULL,(HINSTANCE)
GetWindowLong (hwnd, GWL_HINSTANCE),NULL);
ShowWindow(hChild,SW_SHOWNORMAL);
return 0;/*
while(GetMessage(&m1,NULL,0,0))
{
TranslateMessage(&m1);
DispatchMessage(&m1);
}*/
}
break;
case BN_CLICKED:
MessageBox(NULL,TEXT("THANKS FOR
ALL THE EDUCATION U BESTOWED TO
US"),TEXT("INFO"),MB_ICONINFORMATION);
return 0;
case ID_CHECK:
hdc=GetDC(hwnd);
hFont=CreateFont(30,0,0,0,FW_NORMAL,0,0,0,ANSI_CHARSET,
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
VARIABLE_PITCH|FF_ROMAN,TEXT("ROMAN"));
SelectObject(hdc,hFont);
SetBkColor(hdc, RGB(240,0,0));
SetTextColor (hdc, RGB(150,150,150));
case ID_CHECK_NAME:
hdc=GetDC(hwnd);
hFont=CreateFont(30,0,0,0,FW_NORMAL,0,0,0,ANSI_CHARSET,
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
VARIABLE_PITCH|FF_ROMAN,TEXT("ROMAN"));
SelectObject(hdc,hFont);
SetBkColor(hdc, RGB(0,240,0));
SetTextColor (hdc, RGB(0,0,250));
switch(count)
{
case 1:
TextOut(hdc,30,90,TEXT("A"),1);
count++;break;
case 2:
TextOut(hdc,150,90,TEXT("N"),1);
count++;break;
case 3:
TextOut(hdc,330,90,TEXT("J"),1);
count++;break;
case 4:
TextOut(hdc,450,90,TEXT("A"),1);
count++;
break;
case 5:
TextOut(hdc,30,150,TEXT("N"),1);
count++;break;
case 6:
TextOut(hdc,150,150,TEXT("I"),1);
count++;
break;
case 7:
TextOut(hdc,330,150,TEXT("K"),1);
count++;break;
case 8:
TextOut(hdc,450,150,TEXT("U"),1);
count++;break;
case 9:
TextOut(hdc,30,210,TEXT("N"),1);
count++;break;
case 10:
TextOut(hdc,150,210,TEXT("W"),1);
count++;
break;
case 11:
TextOut(hdc,330,210,TEXT("A"),1);
count++;break;
case 12:
TextOut(hdc,450,210,TEXT("R"),1);
count++;
break;
case 13:
MessageBox(hwnd,TEXT("THATS ALL MA
NAME"),TEXT("Done"),MB_OK);
}
break;
case ID_CHECK_STATIC:
hdc=GetDC(hwnd);
hFont=CreateFont(30,0,0,0,FW_NORMAL,0,0,0,ANSI_CHARSET,
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
VARIABLE_PITCH|FF_ROMAN,TEXT("ROMAN"));
SelectObject(hdc,hFont);
SetBkColor(hdc, RGB(100,100,100));
SetTextColor (hdc, RGB(0,255,0));
TextOut(hdc,270,30,TEXT("D"),1);
TextOut(hdc,270,90,TEXT("P"),1);
TextOut(hdc,270,150,TEXT("R"),1);
TextOut(hdc,270,210,TEXT("O"),1);
TextOut(hdc,270,270,TEXT("B"),1);
TextOut(hdc,270,330,TEXT("L"),1);
TextOut(hdc,270,390,TEXT("E"),1);
TextOut(hdc,270,450,TEXT("M"),1);
break;
ReleaseDC(hwnd,hdc);
DeleteObject(hFont);
break;
case ID_QUIT:
DestroyWindow(hwnd);
break;
case ID_SUM_1STLINE:
case ID_SUM_2NDLINE:
MessageBox(hwnd,TEXT("SUM OF 2ND LINE
CUBE OF NUMBERS ARE:672"),TEXT("sum"),MB_OK);
break;
case ID_SUM_3RDLINE:
MessageBox(hwnd,TEXT("SUM OF 3RD LINE
CUBE OF NUMBERS ARE:416"),TEXT("sum"),MB_OK);
break;
case ID_SUM_4THLINE:
MessageBox(hwnd,TEXT("SUM OF 4TH LINE
CUBE OF NUMBERS ARE:756"),TEXT("sum"),MB_OK);
break;
case ID_SUM_5THLINE:
MessageBox(hwnd,TEXT("SUM OF 5TH LINE
CUBE OF NUMBERS ARE:1404"),TEXT("sum"),MB_OK);
break;
case ID_SUM_6THLINE:
MessageBox(hwnd,TEXT("SUM OF 6TH LINE
CUBE OF NUMBERS ARE:1296"),TEXT("sum"),MB_OK);
break;
case ID_SUM_7THLINE:
MessageBox(hwnd,TEXT("SUM OF 7TH LINE
CUBE OF NUMBERS ARE:1188"),TEXT("sum"),MB_OK);
break;
case ID_SUM_8THLINE:
MessageBox(hwnd,TEXT("SUM OF 8TH LINE
CUBE OF NUMBERS ARE:1080"),TEXT("sum"),MB_OK);
break;
}
break;
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
SetTextColor(hdc,RGB(255,255,255));
SetBkMode(hdc,OPAQUE);
SetBkColor(hdc,RGB(130,130,130));
GetClientRect(hwnd,&rect);
Rectangle(hdc,0,0,1300,800);
for(int i=0;i<300;i+=60)
{
//SetBkColor(hdc,
RGB(0,255,0));
MoveToEx(hdc,600,i,NULL);
LineTo(hdc,1250,i);
}
for(int i=420;i<540;i+=60)
{
//SetBkColor(hdc,
RGB(0,255,0));
MoveToEx(hdc,600,i,NULL);
LineTo(hdc,1250,i);
}
Rectangle(hdc,0,0,560,480);
for(int i=0;i<500;i+=60)
{
//SetBkColor(hdc,
RGB(255,0,0));
MoveToEx(hdc,i,0,NULL);
LineTo(hdc,i,480);
}
for(int i=0;i<480;i+=60)
{
//SetBkColor(hdc,
RGB(0,255,0));
MoveToEx(hdc,0,i,NULL);
LineTo(hdc,560,i);
}
for(int i=30;i<70;i+=60)
{
aa[0] = aaa++;
TextOut(hdc,30,i,aa,1);
}
aaa= TEXT('2');
for(int i=270;i<480;i+=60)
{
aa[0] = aaa++;
TextOut(hdc,30,i,aa,1);
}
aaa= TEXT('4');
for(int i=30;i<240;i+=60)
{
aa[0] = aaa--;
TextOut(hdc,90,i,aa,1);
}
aaa= TEXT('8');
for(int i=270;i<480;i+=60)
{
aa[0] = aaa--;
TextOut(hdc,90,i,aa,1);
}
aaa= TEXT('6');
for(int i=30;i<40;i+=60)
{
aa[0] = aaa++;
TextOut(hdc,150,i,aa,1);
}
aaa= TEXT('7');
for(int i=270;i<390;i+=60)
{
aa[0] = aaa++;
TextOut(hdc,150,i,aa,1);
}
aaa= TEXT('1');
for(int i=390;i<480;i+=60)
{
aa[0] = aaa++;
TextOut(hdc,150,i,aa,1);
}
aaa= TEXT('1');
for(int i=30;i<40;i+=60)
{
aa[0] = aaa--;
TextOut(hdc,210,i,aa,1);
}
aaa= TEXT('8');
for(int i=90;i<480;i+=60)
{
aa[0] = aaa--;
TextOut(hdc,210,i,aa,1);
}
aaa= TEXT('3');
for(int i=30;i<40;i+=60)
{
aa[0] = aaa++;
TextOut(hdc,330,i,aa,1);
}
aaa= TEXT('4');
for(int i=270;i<480;i+=60)
{
aa[0] = aaa++;
TextOut(hdc,330,i,aa,1);
}
aaa= TEXT('6');
for(int i=30;i<390;i+=60)
{
aa[0] = aaa--;
TextOut(hdc,390,i,aa,1);
}
aaa= TEXT('8');
for(int i=390;i<480;i+=60)
{
aa[0] = aaa--;
TextOut(hdc,390,i,aa,1);
}
aaa= TEXT('8');
for(int i=30;i<40;i+=60)
{
aa[0] = aaa++;
TextOut(hdc,450,i,aa,1);
}
aaa= TEXT('1');
for(int i=270;i<480;i+=60)
{
aa[0] = aaa++;
TextOut(hdc,450,i,aa,1);
}
aaa= TEXT('3');
for(int i=30;i<210;i+=60)
{
aa[0] = aaa--;
TextOut(hdc,510,i,aa,1);
}
aaa= TEXT('8');
for(int i=210;i<480;i+=60)
{
aa[0] = aaa--;
TextOut(hdc,510,i,aa,1);
}
TextOut(hdc,30,90,TEXT("A"),1);
TextOut(hdc,150,90,TEXT("N"),1);
TextOut(hdc,330,90,TEXT("J"),1);
TextOut(hdc,450,90,TEXT("A"),1);
TextOut(hdc,30,150,TEXT("N"),1);
TextOut(hdc,150,150,TEXT("I"),1);
TextOut(hdc,330,150,TEXT("K"),1);
TextOut(hdc,450,150,TEXT("U"),1);
TextOut(hdc,30,210,TEXT("N"),1);
TextOut(hdc,150,210,TEXT("W"),1);
TextOut(hdc,330,210,TEXT("A"),1);
TextOut(hdc,450,210,TEXT("R"),1);
TextOut(hdc,600,30,TEXT("SUBMITTED BY:"),15);
TextOut(hdc,600,90,TEXT("NAME:ANJANI PRASAD
KUNWAR"),25);
TextOut(hdc,600,150,TEXT("SECTION:1803"),12);
TextOut(hdc,600,210,TEXT("ROLL NO:10"),10);
TextOut(hdc,600,390,TEXT("SUBMITTED TO:"),15);
TextOut(hdc,600,450,TEXT("JASPREET MAM"),15);
TextOut(hdc,270,30,TEXT("D"),1);
TextOut(hdc,270,90,TEXT("P"),1);
TextOut(hdc,270,150,TEXT("R"),1);
TextOut(hdc,270,210,TEXT("O"),1);
TextOut(hdc,270,270,TEXT("B"),1);
TextOut(hdc,270,330,TEXT("L"),1);
TextOut(hdc,270,390,TEXT("E"),1);
TextOut(hdc,270,450,TEXT("M"),1);
ReleaseDC(hwnd,hdc);
break;
return 0;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc (hwnd, message,
wParam, lParam) ;
}
return 0;
}