Windows Programming: Design Problem

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 20

2010

WINDOWS PROGRAMMING

DESIGN PROBLEM

SUBMITTED TO:

JASPREET MAM SUBMITTED BY :


ANJANI KUNWAR
RA1803A10
10807973
B.TECH(CSE)-H
SOLUTION TO THE DESIGN PROBLEM IS HERE

THEFOLLOWING PROGRAMME CONTAINS


FULL NAME STARTED FROM MA ROLL NO.
9 INTO 8 BLOCKS.
5th VERTICAL LINE RESERVE FOR DESIGN PROBLEM WORDS.
WORDS OF MY NAME ARRANGED IN SPACE OF ONE BLOCKS.
SUM OF CUBE OF ALL NUMBERS IN A HORIZONTAL LINE.
HIGHLIGHTS THE NAME
HIGHLIGHTS THE DESIGN PROBLEM WORD
NUMBERS ARE ARRANGED IN INCREASING AND DECREASING
ORDER ON END OF A VERTICAL LINE AND SO ON.
 CHILD WINDOW
 POPUP WINDOW
CODING

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

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;


LRESULT CALLBACK child(HWND,UINT,WPARAM,LPARAM);
HINSTANCE hinst;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE
hPrevInstance,PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("HELLO") ;
HWND hwnd ;
MSG msg ;
hinst = hInstance;
WNDCLASS wndclass ;
if(!hPrevInstance)
{
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject
(BLACK_PEN ) ;
wndclass.lpszMenuName =NULL;
wndclass.lpszClassName = szAppName ;
if (!RegisterClass (&wndclass))
return 0 ;
wndclass.lpfnWndProc=child;
wndclass.hIcon=NULL;
wndclass.hCursor=LoadCursor(NULL,IDC_CROSS);
wndclass.lpszMenuName= NULL;
wndclass.lpszClassName= TEXT("Childclass");
// register the child window class
if(!RegisterClass(&wndclass))
{
MessageBox(hwnd,TEXT("Can't register child
class"), TEXT("Bye"),MB_OK);
return 0;
}

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

LRESULT CALLBACK WndProc (HWND hwnd, UINT message,


WPARAM wParam, LPARAM lParam)
{
HDC hdc=NULL;
static HMENU menu,pop,popu;
static HWND hChild=NULL;
static int count=1;
TCHAR aaa = TEXT('1');
TCHAR aa[2];
RECT rect;
static HFONT
hFont;//=CreateFont(30,0,0,0,FW_NORMAL,0,0,0,ANSI_CHARS
ET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALI
TY,VARIABLE_PITCH|FF_ROMAN,TEXT("ROMAN"));
PAINTSTRUCT ps;
static int i=1;
switch(message)
{

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:

MessageBox(hwnd,TEXT("SUM OF 1ST LINE


CUBE OF NUMBERS ARE:1064"),TEXT("sum"),MB_OK);
break;

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

LRESULT CALLBACK child(HWND hwnd, UINT message, WPARAM


wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
switch(message)
{
case WM_PAINT:
BeginPaint(hwnd,&ps);
TextOut(ps.hdc,10,25,TEXT("TRADE:BTECH(CSE)-
H"),18);
TextOut(ps.hdc,10,50,TEXT("LOVELY PROFESSIONAL
UNIVERSITY"),30);
EndPaint(hwnd,&ps);
default:
return DefWindowProc (hwnd, message, wParam,
lParam);
}
return 0;
}
SCREEN SHOTS

You might also like