0% found this document useful (0 votes)
125 views

Lab Manual New

This program demonstrates creating windows using MFC in Visual C++ by initializing an instance of the CWinApp class, creating a frame window object derived from CFrameWnd and calling the Run function to display and process messages for the window. It handles basic window creation and message processing to display a simple window form.

Uploaded by

Michael Owens
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
125 views

Lab Manual New

This program demonstrates creating windows using MFC in Visual C++ by initializing an instance of the CWinApp class, creating a frame window object derived from CFrameWnd and calling the Run function to display and process messages for the window. It handles basic window creation and message processing to display a simple window form.

Uploaded by

Michael Owens
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 89

VISUAL PROGRAMMING LAB

SYLLABUS 1.Form Design Keyboard & Mouse events 2.Programs on usage of data types - variant, Contro arrays !."imp e app i#ations using fi e system #ontro s $. Database app i#ations using data #ontro . %."DK type programs for #reating simp e &indo&s &it' different &indo& sty es (. "DK type programs #ode for )eyboard and mouse events, *D+ ob,e#ts. -. "imp e Dia og .ased app i#ation eg. Ca #u ator, interest #omputation, money #onversions, et#. /. Creating "D+ & MD+ app i#ations, Moda and Mode ess dia og. 0.Programming for reading and &riting into do#uments 11. Coding Dynami# #ontro s s ider #ontro , progress #ontro , in'eriting Ctree2ie& and Cri#'edit2ie&. 11.Creating stati# and dynami# sp itter &indo&s 12. Creating D33s and using t'em. 1!. 4inso#) and 4in+net & +nternet 56p orer #ommon #ontro s. 1$. Data a##ess t'roug' 7D.C Cdatabase, Cre#ordset. 1%.Creating 8#tive9 #ontro and using it.

:;ype te6t<

LIST OF PROGRAMS
Sl.no 1. 2. !. $. %. (. -. /. 0. 11 . 11 . 12 . 1! . 1$ . 1% . 1( . 1. 1/ . 10 . 21 . 21 . :;ype te6t< Program Program for )eyboard and mouse events in 2. (.1 Program for performing various )eyboard events 2.(.1 Programs using data types variant 2.(.1 8pp i#ation imp ementing Fi e system #ontro 2.(.1 Database 8pp i#ation using Data #ontro =Frontend> 2.(.1,.a#)end>Ms-8#ess? Creating 4indo&s using 2C@@ Program for performing Keyboard in 2C@@ Program for performing Mouse event in 2C@@ Program for using *D+ too s in 2C@@ Dia og .ased 8pp i#ation-Ca #u ator "ing e Do#ument +nterfa#e in 2C@@. Mu tip e Do#ument +nterfa#e in 2C@@. Creating Moda Dia og .o6 in 2C@@ Creating Mode ess Dia og .o6 in 2C@@ Program for imp ementing "D+ "eria iAation. Program for imp ementing MD+ "eria iAation. Program for imp ementing " ider Contro Program for imp ementing ;ree 2ie& Creation Program for imp ementing Progress #ontro #reation Program for imp ementing "p itter vie& #ontro Program for #reating D33 and using it. Page no $ ( / 11 12 1% 110 2! 2( !1 !$ !$1 $! $( %1 %! %( (1 ($

22 . 2! . 2$ . 2% .

Program for imp ementing 4inso#) #'at program Deve op an app i#ation for performing Data a##ess t'roug' 7D.C Program for Creating 8#tive9 Contro in 2.(.1 Program for 8#tive9 #ontro Dia og #ontainer

(-1 -% -/

VISUAL BASIC PROGRAMMING LAB


Ex.No.1.A Sim le VB A
1. Aim, ;o deve op a simp e 2. app i#ation t'at demonstrates t'e use of mouse and )eyboard 5vents Algori"#m, 1. "tart a ne& pro,e#t by se e#ting standard e6e from ne& pro,e#t dia og bo6 2. 8dd reBuired #oding in different )eyboard and mouse events !. ;'e events are e6e#uted during run time So&r!e Co$e,
Private "ub FormCKeyDo&n=KeyCode 8s +nteger, "'ift 8s +nteger? "e e#t Case "'ift Case vb"'iftMas) Print Dyou pressed t'e s'ift )ey,D Case vbCtr Mas) Print Dyou pressed t'e #tr )ey,D Case vb"'iftMas) @ vb8 tMas) Print Dyou pressed t'e s'ift )ey @ a t )ey,D Case vb8 tMas) Print Dyou pressed t'e a t )ey,D 5nd "e e#t 5nd "ub Private "ub FormCMouseDo&n=.utton 8s +nteger, "'ift 8s +nteger, 9 8s "ing e, E 8s "ing e? Cir# e =9, E?, -% 5nd "ub Private "ub FormCMouseMove=.utton 8s +nteger, "'ift 8s +nteger, 9 8s "ing e, E 8s "ing e? Dra&4idt' F !

li!a"ion "#a" $emon%"ra"e% "#e &%e o' (e)*oar$ an$ mo&%e e+en"%

:;ype te6t<

P"et =9, E? 5nd "ub Private "ub FormCMouseGp=.utton 8s +nteger, "'ift 8s +nteger, 9 8s "ing e, E 8s "ing e? Dim CC7D5 8s +nteger HandomiAe CC7D5 F +nt=1% I Hnd? Fi "ty e F 1 Fi Co or F J.Co or=CC7D5? Cir# e =9, E?, -% 5nd "ub

O&" &",

:;ype te6t<

RESULT, ;'us t'e program 'as been su##essfu y e6e#uted and verified

E-, ../EYBOAR0 EVENTS AIM, ;o i ustrate t'e pro#essing of )eyboard events in 2isua .asi#. ALGORIT1M, 1. 2. !. $. "tart t'e pro#ess Create a ne& form and design it using #omponents in 2isua .asi#. P a#e a abe , te6tbo6 and 2 #ommand buttons. 5vents i)e )eydo&n, )eypress and )eyup are triggered a##ording y by a#tivating t'e button. %. ;'e abe and te6t bo6 disp ays t'e )eyas#ii and #'ara#ter pressed by t'e user. (. "top t'e pro#ess. PROGRAM, Private "ub #mdendCC i#)=? 5nd 5nd "ub Private "ub Command2CKeyDo&n=KeyCode 8s +nteger, "'ift 8s +nteger? 3abe 1.Caption F D8 )ey &as pressed.)ey#odeFD @ "tr=KeyCode? @ Ds'iftFD @ "tr="'ift? 5nd "ub Private "ub Command2CKeyPress=Key8s#ii 8s +nteger? Dim #'ar #'ar F C'r=Key8s#ii? ;e6t1.;e6t F D)ey8s#iiFD @ "tr=Key8s#ii? @ D#'arFD @ #'ar 5nd "ub Private "ub Command2CKeyGp=KeyCode 8s +nteger, "'ift 8s +nteger? 3abe 1.Caption F D8 )ey &as re eased.)ey#odeFD @ "tr=KeyCode? 5nd "ub Private "ub FormCKeyPress=Key8s#ii 8s +nteger? Dim #'ar #'ar F C'r=Key8s#ii? ;e6t1.;e6t F D)ey#odeFD @ "tr=Key8s#ii? @ D#'arFD @ #'ar 5nd "ub

:;ype te6t<

SAMPLE OUTPUT, /EY RELEASE0,

/EY PRESSE0,

RESULT, ;'us t'e form is designed to #apture t'e )ey pressed and t'e #orresponding 8"C++ va ue is disp ayed.

:;ype te6t<

Ex.No.2. Sim le A

li!a"ion T#a" C#e!(% 'or Palin$rome o' A %"ring 3i"# $i''eren" $a"a ") e%

Aim, ;o deve op a simp e app i#ation to reverse a given string and to #'e#) &'et'er t'e string is pa indrome and #on#atenate t&o strings and to sear#' a substring in a string Con"rol% U%e$, La*el% Tex"*oxe% Comman$ B&""on% Algori"#m, 1. "tart a ne& pro,e#t by se e#ting standard e6e from ne& pro,e#t dia og bo6 2. 8dd a te6tbo6 and #ommand buttons to t'e form !. 8dd appropriate #ode for #ommand buttons So&r!e !o$e, 7ption 56p i#it Dim str1 ,str2 ,str! 8s "tring Dim i,, , m, n 8s integer Private "ub #mdC#on#atCC i#)=? ;6tC#on#at.;e6t F t6tCfir.;e6t & t6t Cse#.;e6t 5nd "ub Private "ub #mdCpa inC i#)=? "tr1F;rim=t6tCfir.;e6t? F3en=str1? for iF 1 to 1 step - 1 str!Fstr! @ Mid =str1, +, 1? ne6t i t6tCrev.;e6t F str! if str1 F str! t'en Msgbo6 K"tring is a pa indromeL 5 se Msgbo6 K"tring is not a Pa indrome K 5nd if 5nd sub Private "ub #mdCresCC i#)=? ;6tCfir.;e6t F K K ;6tCse#.;e6t F K K ;6tC#on#at.;e6t F K K ;6tCrev.;e6t F K K :;ype te6t<

;6tCfir."etFo#us 5nd "ub Private "ub #mdCsubCC i#) =? Dim f ag 8s .oo ean "tr1 F ;rim=t6tCfir.;e6t? "tr2 F ;rim=t6tCse#.;e6t? mF en=str1? nF en=str2? For i F 1 to m For , F 1 to n +f=mid=str1 , + ,1? F Mid=str2 , , , ? or Mid=str1 ,+ 1?MN K K ? ;'en F agFtrue 5 se F agFfa se 5nd if Oe6t , Oe6t i +f f agF true t'en Msgbo6 K"ubstring of string oneL 5 se Msgbo6 KOot a substring of string oneL 5nd if 5nd sub OUTPUT

RESULT, ;'us t'e program for using data types 'as been su##essfu y e6e#uted and verified

:;ype te6t<

Ex.No.4.A AIM,

li!a"ion !rea"ion 3i"# File S)%"em Con"rol

;o #reate an emp oyee app i#ation using 2. t'at demonstrates t'e Fi e "ystem Contro used
Algori"#m, 1. "tart a ne& pro,e#t by se e#ting standard e6e from ne& pro,e#t dia og bo6 2. 8dd a Fi e 3ist .o6, Dire#tory 3ist .o6, Drive 3ist .o6 and #ommand buttons to t'e form !. 8dd appropriate #ode to disp ay t'e fi es in Fi e3ist .o6 of Oorma fi e, Pidden Fi es, Head7n y Fi es, "ystem Fi es, Fi es &it' ar#'ive bit on $. 8dd appropriate #ode to disp ay t'e se e#ted fi es in t'e Fi e 3ist .o6 by "e e#ting t'e drive from t'e Drive3ist .o6 and sub dire#tory from t'e dire#tory 3ist .o6

So&r!e Co$e, Private "ub C'e#)1CC i#)=? Fi e1."ystem F C'e#)1.2a ue 5nd "ub Private "ub C'e#)2CC i#)=? Fi e1.Head7n y F C'e#)2.2a ue 5nd "ub Private "ub C'e#)!CC i#)=? Fi e1.Oorma F C'e#)2.2a ue 5nd "ub Private "ub C'e#)$CC i#)=? Fi e1.Pidden F C'e#)2.2a ue 5nd "ub Private "ub Command1CC i#)=? Fi e1.Fi eOame F Df>QdeQ##QI.mdbID 5nd "ub Private "ub Dir1CC'ange=? Fi e1.Pat' F Dir1.Pat' Dir2.Pat' F Drive1.Drive 5nd "ub

:;ype te6t<

O&" &",

RESULT, ;'us t'e program for fi e system #ontro s 'as been su##essfu y e6e#uted and verified

:;ype te6t<

Ex.No.5.0a"a*a%eA AIM,

li!a"ion &%ing 0a"a !on"rol

;o #reate an voter information system app i#ation using 2. as front end and 7ra# e as ba#)end. Pro!e$&re, 1. Create a form in 2isua .asi# 'aving abe s,te6t bo6es, #ommand buttons and a data #ontro .
2. Conne#t t'e form &it' 7H8C35. !. Conne#t t'e front end and ba#)end. $. For ea#' #ommand button, )ey in t'e #odings. %. For adding re#ords, enter t'e data in te6tbo6 and # i#) add. (. For # earing re#ords, use # ear. -. For modifying data va ues, enter appropriate va ues and # i#) modify. /. For de eting, # i#) de ete #ommand button 0. For vie&ing of t'e re#ords, # i#) vie& #ommand button. 11. Fina y, # i#) # ose to # ose t'e 2. form.

Program !o$e, ;ab e #reation #reate tab e voter=id number=%? primary )ey, name var#'ar2=2%?,address var#'ar2=%1?,age number=!?,gender var#'ar2=(?,dob var#'ar2=!1??R #reate tab e votertemp=id number=%? primary )ey, name var#'ar2=2%?,address var#'ar2=%1?,age number=!?,gender var#'ar2=(?,dob var#'ar2=!1??R Private "ub #ommand1C# i#)=? adod#1.addne& 5nd "ub Private "ub #ommand2C# i#)=? adod#1.update 5nd "ub Private "ub #ommand!C# i#)=? adod#1.de ete 5nd "ub

OUTPUT,
:;ype te6t<

. RESULT, ;'us t'e app i#ation for data base #onne#tions 'as been su##essfu y deve oped and verified

:;ype te6t<

VISUALC66 PROGRAMMING

:;ype te6t<

E-,7 .CREATION OF 8IN0O8S Aim, ;o &rite a 2isua C@@ program for #reating a &indo& using &in!2 app i#ation. Logi!al 0e%!ri "ion, ;'e program starts &it' ob,e#t #reation. 8fter initia iAing t'e instan#e, t'e user #reated &indo& is assigned as main &indo&. Gsing "'o& &indo& option pro,e#t user #reated &indo&. Algori"#m, $. "tart t'e Pro#ess %. Create an ob,e#t for an # ass &'i#' in'erits C4in8pp (. ;'e ob,e#t a##ess +nit+nstan#e=? fun#tion -. Create a pointer ob,e#t for t'e # ass &'i#' in'erits CFrame4indo& by a o#ating t'e memory to t'e ob,e#t /. "'o& t'e #reated &indo& using "4C"P74O7HM83 0. "top t'e pro#ess So&r!e Co$e, Sin# udeMaf6&in.'N # ass my&nd > pub i# CFrame4nd T pub i#> my&nd=? T Create=1, DMy &indo&D?R U UR # ass myapp> pub i# C4in8pp T pub i# > .773 +nit+nstan#e=? T my&nd IpR p F ne& my&ndR mCpMain4nd F p R VV main t'read p-N"'o&4indo&="4C"P74O7HM83?R return ;HG5R U UR myapp 8R O&" &",

:;ype te6t<

RESULT, ;'us t'e program for #reating &indo&s 'as been su##essfu y e6e#uted and verified

:;ype te6t<

E-, 9./EYBOAR0 EVENTS IN VC66 AIM, ;o #reate a dia og based app i#ation s'o&#asing different mouse pointer depending on t'e )ey pressed in 2C@@ environment. ALGORIT1M, 7pen Oe& Pro,e#t as Dia og .ased 8pp i#ation. *o to 2ie& Menu, se e#t C ass4iAard and Message Map tab. 8dd Keydo&n message fun#tion to t'e program and edit t'e #ode. De# are t'e variab e s#'ar as C'ar. +f )ey W8X is pressed, t'en 48+; i#on #ursor &i be disp ayed. +f )ey W.X is pressed , t'en .58M i#on #ursor &i be disp ayed. +f )ey WCX is pressed, t'en 8HH74 i#on &i be disp ayed. .ui d and run t'e program PROGRAM, void CKeydo&nD g>>7nKeyDo&n=G+O; nC'ar, G+O; nHepCnt, G+O; nF ags? T VV ;7D7> 8dd your message 'and er #ode 'ere andVor #a defau t #'ar s#'arR PCGH"7H '#ursorR s#'arF#'ar=nC'ar?R if= s#'arFFY1Y? T '#ursorF8f6*et8pp=?-N3oad"tandardCursor=+DCC48+;?R "etCursor= '#ursor?R U if= s#'arFFY2Y? T '#ursorF8f6*et8pp=?-N3oad"tandardCursor=+DCC+.58M?R "etCursor= '#ursor?R U if= s#'arFFY!Y? T '#ursorF8f6*et8pp=?-N3oad"tandardCursor=+DCC8HH74?R "etCursor= '#ursor?R U CDia og>>7nKeyDo&n=nC'ar, nHepCnt, nF ags?R U

SAMPLE OUTPUT, :;ype te6t<

RESULT, ;'us t'e 2C@@ program s'o&#asing different mouse pointers based on t'e )eys pressed is e6e#uted su##essfu y.

:;ype te6t<

E-, :..MOUSE EVENTS IN VC66 AIM, ;o #reate a dia og based app i#ation t'at demonstrates t'e mouse move operations in 2C@@ environment. ALGORIT1M, 1. 7pen Oe& Pro,e#t as Dia og .ased 8pp i#ation. 2. *o to 2ie& Menu, se e#t C ass4iAard and Message Map tab. !. De# are t'e member variab es mCiprev6, mCiprevy as integer type. $. 8dd Mousemove message fun#tion to t'e program from t'e C ass4iAard and edit t'e #ode. %. Create ob,e#t d# for # ass CC ientDC. (. 8 free 'and ine is dra&n using 3ine;o=? and Move;o=? met'ods. -. .ui d and run t'e program. PROGRAM, VV moumoveD g.' > 'eader fi e # ass CMoumoveD g > pub i# CDia og T pub i#> CMoumoveD g=C4ndI pParent F OG33?R VV standard #onstru#tor int 'i#onR int mCiprev6R int mCiprevyR prote#ted> P+C7O mC'+#onR U VV moumoveD g.#pp > imp ementation fi e Sin# ude Dstdaf6.'D Sin# ude Dmoumove.'D Sin# ude DmoumoveD g.'D Sifdef CD5.G* Sdefine ne& D5.G*CO54 Sundef ;P+"CF+35 stati# #'ar ;P+"CF+35:< F CCF+35CCR Sendif VV C8boutD g dia og used for 8pp 8bout # ass C8boutD g > pub i# CDia og T pub i#> C8boutD g=?R prote#ted> virtua void DoData56#'ange=CData56#'angeI pD9? VV +mp ementation prote#ted> VVTT8F9CM"*=C8boutD g? VVUU8F9CM"* D5C38H5CM5""8*5CM8P=? UR :;ype te6t<

C8boutD g>>C8boutD g=? > CDia og=C8boutD g>>+DD? T U void C8boutD g>>DoData56#'ange=CData56#'angeI pD9? T CDia og>>DoData56#'ange=pD9?R U .5*+OCM5""8*5CM8P=C8boutD g, CDia og? 5ODCM5""8*5CM8P=? VV CMoumoveD g dia og CMoumoveD g>>CMoumoveD g=C4ndI pParent VIFOG33IV? > CDia og=CMoumoveD g>>+DD, pParent? T mC'+#on F 8f6*et8pp=?-N3oad+#on=+DHCM8+OFH8M5?R U void CMoumoveD g>>DoData56#'ange=CData56#'angeI pD9? T CDia og>>DoData56#'ange=pD9?R U .5*+OCM5""8*5CM8P=CMoumoveD g, CDia og? VVTT8F9CM"*CM8P=CMoumoveD g? 7OC4MC"E"C7MM8OD=? 7OC4MCP8+O;=? 7OC4MCJG5HEDH8*+C7O=? 7OC.OCC3+CK5D=+DCC.G;;7O1, 7n.utton1? 7OC4MCM7G"5M725=? VVUU8F9CM"*CM8P 5ODCM5""8*5CM8P=? VV CMoumoveD g message 'and ers .773 CMoumoveD g>>7n+nitDia og=? T CDia og>>7n+nitDia og=?R VV +DMC8.7G;.79 must be in t'e system #ommand range. 8""5H;==+DMC8.7G;.79 & 16FFF1? FF +DMC8.7G;.79?R 8""5H;=+DMC8.7G;.79 M 16F111?R CMenuI p"ysMenu F *et"ystemMenu=F83"5?R if =p"ysMenu ZF OG33? T C"tring str8boutMenuR str8boutMenu.3oad"tring=+D"C8.7G;.79?R if =Zstr8boutMenu.+s5mpty=?? T p"ysMenu-N8ppendMenu=MFC"5P8H8;7H?R p"ysMenu-N8ppendMenu=MFC";H+O*, +DMC8.7G;.79, str8boutMenu?R U U :;ype te6t<

VV "et t'e i#on for t'is dia og. ;'e frame&or) does t'is automati#a y VV &'en t'e app i#ationYs main &indo& is not a dia og "et+#on=mC'+#on, ;HG5?R VV "et big i#on "et+#on=mC'+#on, F83"5?R VV "et sma i#on VV ;7D7> 8dd e6tra initia iAation 'ere return ;HG5R VV return ;HG5 un ess you set t'e fo#us to a #ontro U void CMoumoveD g>>7n"ysCommand=G+O; n+D, 3P8H8M Param? T if ==n+D & 16FFF1? FF +DMC8.7G;.79? T C8boutD g d g8boutR d g8bout.DoModa =?R U e se T CDia og>>7n"ysCommand=n+D, Param?R U U void CMoumoveD g>>7nPaint=? T if =+s+#oni#=?? T CPaintDC d#=t'is?R VV devi#e #onte6t for painting "endMessage=4MC+C7O5H8"5.K*OD, =4P8H8M? d#.*et"afePd#=?, 1?R VV Center i#on in # ient re#tang e int #6+#on F *et"ystemMetri#s="MCC9+C7O?R int #y+#on F *et"ystemMetri#s="MCCE+C7O?R CHe#t re#tR *etC ientHe#t=&re#t?R int 6 F =re#t.4idt'=? - #6+#on @ 1? V 2R int y F =re#t.Peig't=? - #y+#on @ 1? V 2R VV Dra& t'e i#on d#.Dra&+#on=6, y, mC'+#on?R U e se T CDia og>>7nPaint=?R U U VV ;'e system #a s t'is to obtain t'e #ursor to disp ay &'i e t'e user drags VV t'e minimiAed &indo&. PCGH"7H CMoumoveD g>>7nJueryDrag+#on=? T return =PCGH"7H? mC'+#onR U void CMoumoveD g>>7n.utton1=? :;ype te6t<

T U void CMoumoveD g>>7nMouseMove=G+O; nF ags, CPoint point? T VV ;7D7> 8dd your message 'and er #ode 'ere andVor #a defau t if==nF ags &MKC3.G;;7O?FFMKC3.G;;7O? T CC ientD# d#=t'is?R d#.Moveto=mCiPrev6,mCiPrevy?R d#.3ine;o=point 6,point y?R mCiprev6Fpoint.6R mCiprevyFpoint.yR U CDia og>>7nMouseMove=nF ags, point?R U

SAMPLE OUTPUT,

RESULT, ;'us t'e program in 2C@@ to dra& a ine &'en mouse is moved 'as been e6e#uted su##essfu y.

:;ype te6t<

E-,;.GRAP1ICAL 0EVICE INTERFACE


Aim, ;o &rite a 2isua C@@ program &'i#' uses t'e *D+ too s Logi!al 0e%!ri "ion, ;'e program starts &it' ob,e#t #reation. 8fter initia iAing t'e instan#e, t'e user #reated &indo& is assigned as main &indo&. Gsing "'o& &indo& option pro,e#t user #reated &indo&. Gsing message map #reate a pen & brus'. Gsing t'at pen & brus' dra& ob,e#ts. Algori"#m, 1. "tart t'e Pro#ess .. Create an ob,e#t for an myapp # ass. +nvo)e +nit+nstan#e fun#tion and #reate ob,e#t for my&in to #a t'e #onstru#tor my&in. 2. 8 &indo& is #reated by #a ing t'e #reate fun#tion &'i#' resides inside t'e #onstru#tor 4. +nside message map &rite t'e #ode for *D+ ob,e#ts i)e pen & brus' . 5. "'o& t'e #reated &indo& using "4C"P74O7HM83 7. "top t'e pro#ess So&r!e Co$e, Sin# ude Maf6&in.'N # ass my&nd > pub i# CFrame4nd T pub i#> my&nd=? T Create=1,DMFCD?R U D5C38H5CM5""8*5CM8P=? void 7n3.uttonDo&n=G+O; f,CPoint p? T CPen penR C.rus' brus'R CC ientDC d#=t'is?R pen.CreatePen=P"C"73+D, %,H*.=211,121,1!1??R brus'.CreatePat#'.rus'=P"C25H;+C83,H*.=%1,%1,1!1??R d#."e e#t7b,e#t=pen?R d#."e e#t7b,e#t=brus'?R d#.He#tang e=211,211,!11,!11?R U void 7nH.uttonDo&n=G+O; f,CPoint p? T CPen penR C.rus' brus'R :;ype te6t<

CC ientDC d#=t'is?R pen.CreatePen=P"C"73+D, %,H*.=12!,1!$,1!1??R brus'.CreatePat#'.rus'=P"CP7H+[7O;83,H*.=1%1,1%1,2!1??R d#."e e#t7b,e#t=pen?R d#."e e#t7b,e#t=brus'?R d#.He#tang e=%1,%1,211,211?R U UR .5*+OCM5""8*5CM8P=my&nd,CFrame4nd? 7OC4MC3.G;;7OD74O=? 7OC4MCH.G;;7OD74O=? 5ODCM5""8*5CM8P=? # ass myapp > pub i# C4in8pp T pub i#> .773 +nit+nstan#e=? T my&nd IpR p F ne& my&nd=?R mCpMain4nd F pR p-N"'o&4indo&="4C"P74O7HM83?R return trueR U UR myapp 8R

O&" &", :;ype te6t<

RESULT, ;'us t'e program for *D+ 'as been su##essfu y e6e#uted and verified

:;ype te6t<

E-, 1<.0IALOG BASE0 APPLICATION = CALCULATOR AIM, ;o &rite a 2C@@ program in dia og based mode to perform arit'meti# operations. ALGORIT1M, 1. 7pen Oe& Pro,e#t as Dia og .ased 8pp i#ation. 2. 8dd #omponents i)e edit bo6, stati# bo6 and #ommand button to t'e dia og bo6. !. De# are t'e ne#essary member variab es using C ass4iAard for t'e edit bo6es. $. De# are t'e ne#essary member fun#tions using C ass4iAard for various operations i)e 8DD,"G.,D+2,MG3,C358H. %. .ui d t'e pro#ess. (. Hun t'e program and obtain t'e resu t. PROGRAM, VV #a #D g.#pp > imp ementation fi e Sin# ude Dstdaf6.'D Sin# ude D#a #.'D Sin# ude D#a #D g.'D Sifdef CD5.G* Sdefine ne& D5.G*CO54 Sundef ;P+"CF+35 stati# #'ar ;P+"CF+35:< F CCF+35CCR Sendif VV C8boutD g dia og used for 8pp 8bout # ass C8boutD g > pub i# CDia og T pub i#> C8boutD g=?R VV Dia og Data VVTT8F9CD8;8=C8boutD g? enum T +DD F +DDC8.7G;.79 UR VVUU8F9CD8;8 VV C ass4iAard generated virtua fun#tion overrides VVTT8F9C2+H;G83=C8boutD g? prote#ted> virtua void DoData56#'ange=CData56#'angeI pD9?R VV DD9VDD2 support VVUU8F9C2+H;G83 VV +mp ementation prote#ted> VVTT8F9CM"*=C8boutD g? VVUU8F9CM"* D5C38H5CM5""8*5CM8P=? UR C8boutD g>>C8boutD g=? > CDia og=C8boutD g>>+DD? T VVTT8F9CD8;8C+O+;=C8boutD g? VVUU8F9CD8;8C+O+; :;ype te6t<

U void C8boutD g>>DoData56#'ange=CData56#'angeI pD9? T CDia og>>DoData56#'ange=pD9?R VVTT8F9CD8;8CM8P=C8boutD g? VVUU8F9CD8;8CM8P U .5*+OCM5""8*5CM8P=C8boutD g, CDia og? VVTT8F9CM"*CM8P=C8boutD g? VV Oo message 'and ers VVUU8F9CM"*CM8P 5ODCM5""8*5CM8P=? VV CCa #D g dia og CCa #D g>>CCa #D g=C4ndI pParent VIFOG33IV? > CDia og=CCa #D g>>+DD, pParent? T VVTT8F9CD8;8C+O+;=CCa #D g? mCv1 F 1R mCv2 F 1R mCv! F 1R VVUU8F9CD8;8C+O+; VV Oote t'at 3oad+#on does not reBuire a subseBuent Destroy+#on in 4in!2 mC'+#on F 8f6*et8pp=?-N3oad+#on=+DHCM8+OFH8M5?R U void CCa #D g>>DoData56#'ange=CData56#'angeI pD9? T CDia og>>DoData56#'ange=pD9?R VVTT8F9CD8;8CM8P=CCa #D g? DD9C;e6t=pD9, +DCC5D+;1, mCv1?R DD9C;e6t=pD9, +DCC5D+;2, mCv2?R DD9C;e6t=pD9, +DCC5D+;!, mCv!?R VVUU8F9CD8;8CM8P U .5*+OCM5""8*5CM8P=CCa #D g, CDia og? VVTT8F9CM"*CM8P=CCa #D g? 7OC4MC"E"C7MM8OD=? 7OC4MCP8+O;=? 7OC4MCJG5HEDH8*+C7O=? 7OC.OCC3+CK5D=+DCC.G;;7O1, 7nadd? 7OC.OCC3+CK5D=+DCC.G;;7O2, 7nsub? 7OC.OCC3+CK5D=+DCC.G;;7O!, 7nmu ? 7OC.OCC3+CK5D=+DCC.G;;7O$, 7ndiv? 7OC.OCC3+CK5D=+DCC.G;;7O%, 7n# ear? VVUU8F9CM"*CM8P 5ODCM5""8*5CM8P=? VV CCa #D g message 'and ers .773 CCa #D g>>7n+nitDia og=? T :;ype te6t<

CDia og>>7n+nitDia og=?R VV 8dd D8bout...D menu item to system menu. VV +DMC8.7G;.79 must be in t'e system #ommand range. 8""5H;==+DMC8.7G;.79 & 16FFF1? FF +DMC8.7G;.79?R 8""5H;=+DMC8.7G;.79 M 16F111?R CMenuI p"ysMenu F *et"ystemMenu=F83"5?R if =p"ysMenu ZF OG33? T C"tring str8boutMenuR str8boutMenu.3oad"tring=+D"C8.7G;.79?R if =Zstr8boutMenu.+s5mpty=?? T p"ysMenu-N8ppendMenu=MFC"5P8H8;7H?R p"ysMenu-N8ppendMenu=MFC";H+O*, +DMC8.7G;.79, str8boutMenu?R U U VV "et t'e i#on for t'is dia og. ;'e frame&or) does t'is automati#a y VV &'en t'e app i#ationYs main &indo& is not a dia og "et+#on=mC'+#on, ;HG5?R VV "et big i#on "et+#on=mC'+#on, F83"5?R VV "et sma i#on VV ;7D7> 8dd e6tra initia iAation 'ere return ;HG5R VV return ;HG5 un ess you set t'e fo#us to a #ontro U void CCa #D g>>7n"ysCommand=G+O; n+D, 3P8H8M Param? T if ==n+D & 16FFF1? FF +DMC8.7G;.79? T C8boutD g d g8boutR d g8bout.DoModa =?R U e se T CDia og>>7n"ysCommand=n+D, Param?R U U VV +f you add a minimiAe button to your dia og, you &i need t'e #ode be o& VV to dra& t'e i#on. For MFC app i#ations using t'e do#umentVvie& mode , VV t'is is automati#a y done for you by t'e frame&or). void CCa #D g>>7nPaint=? T if =+s+#oni#=?? T CPaintDC d#=t'is?R VV devi#e #onte6t for painting "endMessage=4MC+C7O5H8"5.K*OD, =4P8H8M? d#.*et"afePd#=?, 1?R VV Center i#on in # ient re#tang e :;ype te6t<

int #6+#on F *et"ystemMetri#s="MCC9+C7O?R int #y+#on F *et"ystemMetri#s="MCCE+C7O?R CHe#t re#tR *etC ientHe#t=&re#t?R int 6 F =re#t.4idt'=? - #6+#on @ 1? V 2R int y F =re#t.Peig't=? - #y+#on @ 1? V 2R VV Dra& t'e i#on d#.Dra&+#on=6, y, mC'+#on?R U e se T CDia og>>7nPaint=?R U U VV ;'e system #a s t'is to obtain t'e #ursor to disp ay &'i e t'e user drags VV t'e minimiAed &indo&. PCGH"7H CCa #D g>>7nJueryDrag+#on=? T return =PCGH"7H? mC'+#onR U void CCa #D g>>7nadd=? T VV ;7D7> 8dd your #ontro notifi#ation 'and er #ode 'ere GpdateData=1?R mCv!F mCv1 @ mCv2R GpdateData=1?R U void CCa #D g>>7nsub=? T VV ;7D7> 8dd your #ontro notifi#ation 'and er #ode 'ere GpdateData=1?R mCv!F mCv1 - mCv2R GpdateData=1?R U void CCa #D g>>7nmu =? T VV ;7D7> 8dd your #ontro notifi#ation 'and er #ode 'ere GpdateData=1?R mCv!F mCv1 I mCv2R GpdateData=1?R U void CCa #D g>>7ndiv=? T VV ;7D7> 8dd your #ontro notifi#ation 'and er #ode 'ere GpdateData=1?R :;ype te6t<

mCv!F mCv1 V mCv2R GpdateData=1?R U void CCa #D g>>7n# ear=? T VV ;7D7> 8dd your #ontro notifi#ation 'and er #ode 'ere GpdateData=1?R mCv1F1R mCv2F1R mCv!F1R GpdateData=1?R U void CCa #D g>>7n5OD=? T VV ;7D7> 8dd your #ontro notifi#ation 'and er #ode 'ere 7n7KR U SAMPLE OUTPUT,

RESULT, ;'us t'e program t'at performs arit'meti# operation using 2C@@ 'as been e6e#uted su##essfu y.

:;ype te6t<

E-, 11..SINGLE 0OCUMENT INTERFACE

AIM,
;o #reate "D+ app i#ations for various )ey events

PROCE0URE,
"tep 1> 7pen MFC 8pp i#ation 4iAard =e6e? pro,e#t "tep 2> ;ype your pro,e#t name and se e#t appropriate o#ation "tep !> "e e#t "D+ do#ument and se e#t finis' option "tep $> *o to resour#e vie& -N "e e#t t'e menu option and go to C ass 4iAard se e#t )ey 5vents su#' as Key up Key do&n 8nd fet#' your sour#e #ode for t'e )ey events "tep (> .ui d t'e "D+ app i#ations of various )ey events

"tep %> Create member fun#tion for )ey up and )ey do&n as 7n)eyGp and 7n)eyDo&n

CO0ING,
:;ype te6t<

KeyeView.cpp
Sin# ude Dstdaf6.'D Sin# ude D)eye.'D Sin# ude D)eyeDo#.'D Sin# ude D)eye2ie&.'D

CKeyeView
+MP35M5O;CDEOCH58;5=CKeye2ie&, C2ie&? .5*+OCM5""8*5CM8P=CKeye2ie&, C2ie&? VVTT8F9CM"*CM8P=CKeye2ie&? 7OC4MCK5ED74O=? 7OC4MCK5EGP=? VVUU8F9CM"*CM8P VV "tandard printing #ommands 7OCC7MM8OD=+DCF+35CPH+O;, C2ie&>>7nFi ePrint? 7OCC7MM8OD=+DCF+35CPH+O;CD+H5C;, C2ie&>>7nFi ePrint? 7OCC7MM8OD=+DCF+35CPH+O;CPH52+54, C2ie&>>7nFi ePrintPrevie&? 5ODCM5""8*5CM8P=?s

CKeyeView message handlers


void CKeye2ie&>>7nKeyDo&n=G+O; nC'ar, G+O; nHepCnt, G+O; nF ags? T VV ;7D7> 8dd your message 'and er #ode 'ere andVor #a defau t C0C> $!?Ge"0C@AB $!CDElli %e@2<E2<E.<<E.<<AB C2ie&>>7nKeyDo&n=nC'ar, nHepCnt, nF ags?R U void CKeye2ie&>>7nKeyGp=G+O; nC'ar, G+O; nHepCnt, G+O; nF ags? T VV ;7D7> 8dd your message 'and er #ode 'ere andVor #a defau t C0C> $!?Ge"0C@AB $!CDRe!"angle@5<E5<E.<<E.<<AB C2ie&>>7nKeyGp=nC'ar, nHepCnt, nF ags?R U

:;ype te6t<

OUTPUT,

:;ype te6t<

RESULT,
;'us t'e #ode for "D+ using )eyboard events is e6e#uted and verified su##essfu y

:;ype te6t<

E-,1..MULTIPLE 0OCUMENT INTERFACE

AIM,
;o #reate MD+ app i#ations for various )ey events

PROCE0URE,
"tep 1> 7pen MFC 8pp i#ation 4iAard =e6e? pro,e#t "tep 2> ;ype your pro,e#t name and se e#t appropriate o#ation "tep !> "e e#t MD+ do#ument and se e#t finis' option "tep $> *o to resour#e vie& -N "e e#t t'e menu option and go to C ass 4iAard se e#t )ey 5vents su#' as Key up Key do&n 8nd fet#' your sour#e #ode for t'e )ey events "tep (> .ui d t'e MD+ app i#ations of various )ey events

"tep %> Create member fun#tion for )ey up and )ey do&n as 7n)eyGp and 7n)eyDo&n

:;ype te6t<

CO0ING,

KeyeView.cpp
Sin# ude Dstdaf6.'D Sin# ude D)eye.'D Sin# ude D)eyeDo#.'D Sin# ude D)eye2ie&.'D

CKeyeView
+MP35M5O;CDEOCH58;5=CKeye2ie&, C2ie&? .5*+OCM5""8*5CM8P=CKeye2ie&, C2ie&? VVTT8F9CM"*CM8P=CKeye2ie&? 7OC4MCK5ED74O=? 7OC4MCK5EGP=? VVUU8F9CM"*CM8P VV "tandard printing #ommands 7OCC7MM8OD=+DCF+35CPH+O;, C2ie&>>7nFi ePrint? 7OCC7MM8OD=+DCF+35CPH+O;CD+H5C;, C2ie&>>7nFi ePrint? 7OCC7MM8OD=+DCF+35CPH+O;CPH52+54, C2ie&>>7nFi ePrintPrevie&? 5ODCM5""8*5CM8P=?s

CKeyeView message handlers


void CKeye2ie&>>7nKeyDo&n=G+O; nC'ar, G+O; nHepCnt, G+O; nF ags? T VV ;7D7> 8dd your message 'and er #ode 'ere andVor #a defau t C0C> $!?Ge"0C@AB $!CDElli %e@2<E2<E.<<E.<<AB C2ie&>>7nKeyDo&n=nC'ar, nHepCnt, nF ags?R U void CKeye2ie&>>7nKeyGp=G+O; nC'ar, G+O; nHepCnt, G+O; nF ags? T VV ;7D7> 8dd your message 'and er #ode 'ere andVor #a defau t :;ype te6t<

C0C> $!?Ge"0C@AB $!CDRe!"angle@5<E5<E.<<E.<<AB C2ie&>>7nKeyGp=nC'ar, nHepCnt, nF ags?R U

OUTPUT,

:;ype te6t<

RESULT,
;'us t'e #ode for MD+ using )eyboard events is e6e#uted and verified su##essfu y

:;ype te6t<

E-, 12.CREATING MO0AL 0IALOG BOAIM, ;o &rite a program in 2C@@ to deve op a moda dia og bo6 =#ommon and #ustom? using dia og based app i#ation. ALGORIT1M, 1. 7pen Oe& Pro,e#t as Dia og based app i#ation. 2. Design t'e dia og using #omponents i)e edit bo6, #ommand button, stati# and edit bo6. !. 8dd member variab es for 4P+CP7P;+7O button and edit bo6es name y mCsresu ts,mC&'i#'option respe#tive y in dia og bo6. $. *o to resour#e vie& for #reating a #ustom dia og by # i#)ing +nsert Dia og option. %. 8dd respe#tive #omponents in t'e #ustom dia og bo6 and asso#iate &it' t'em t'e reBuired member variab es. (. Create a ne& # ass CMsgD g for #ustom dia og bo6. -. .ind t'e ne#essary member variab es for t'e #ontro s p a#ed in #ustom dia og bo6. /. +nsert 'eader MsgD g.' in CCommonDia ogD g.CPP =.ase dia og? by using Fi e vie&. 0. 8dd member variab e mCdMsgD g for # ass CMsgD g in base # ass CCommonDia ogD g in private mode. 11. +ntegrate appropriate #odings for #ommand button 4P+CP7P;+7O, E5"O7C8OC53, 8.7H;H5;HE+*O7H5, F+357P5O, CG";7MD+837*. 11. "uitab e message bo6es are disp ayed for t'e respe#tive buttons &'en triggered. 12. F+357P5O button demands t'e se e#tion of fi ename using Common dia og bo6. 1!. ;riggering of 4P+CP7P;+7O button so i#it t'e disp ay of resu t =option se e#ted from #ustom dia og? in t'e base dia og =C7MM7O D+837*?. 1$. .ui d and run t'e program. PROGRAM, VV C7MD3*D g.#pp > imp ementation fi e Sin# ude Dstdaf6.'D Sin# ude DC7MD3*.'D Sin# ude Dmsgd g.'D Sin# ude DC7MD3*D g.'D Sifdef CD5.G* Sdefine ne& D5.G*CO54 Sundef ;P+"CF+35 stati# #'ar ;P+"CF+35:< F CCF+35CCR Sendif void CC7MD3*D g>>7nEesno#an#e =? T int iresR

:;ype te6t<

iresFMessage.o6=DPress t'e yes, no or #an#e buttonD,DE5",O7,C8OC53.D+837*D,M.CE5"O7C8OC53\M.C+C7O+OF7HM8;+7O?R s&it#'=ires? T #ase +DE5"> mCresFDEes is pressedDR brea)R #ase +DO7> mCresFDOo is pressedDR brea)R #ase +DC8OC53> mCresFDCan#e is pressedDR brea)R U GpdateData=F83"5?R U void CC7MD3*D g>>7n5nd=? T VV ;7D7> 8dd your #ontro notifi#ation 'and er #ode 'ere 7n7K=?R U void CC7MD3*D g>>7n8bortretryignore=? T int iresR iresFMessage.o6=DPress t'e 8.7H;, H5;HE or +*O7H5 buttonD,D8.7H;,H5;HE,+*O7H5.D+837*D,M.C8.7H;H5;HE+*O7H5\ M.C+C7O+OF7HM8;+7O?R s&it#'=ires? T #ase +D8.7H;> mCresFD8.7H;is pressedDR brea)R #ase +DH5;HE> mCresFDH5;HE is pressedDR brea)R #ase +D+*O7H5> mCresFD+*O7H5 is pressedDR brea)R U GpdateData=F83"5?R U void CC7MD3*D g>>7nFi eopen=? T CFi eDia og mC+DFi e=;HG5?R if=mC+DFi e.DoModa =?FF+D7K? T mCresFmC+DFi e.*etFi eOame=?R GpdateData=F83"5?R U U :;ype te6t<

void CC7MD3*D g>>7nCustomd g=? T if=mCmsgd g.DoModa =?FF+D7K? T mCresFmCmsgd g.mCsmsgR GpdateData=F83"5?R mC&opt.5nab e4indo&=;HG5?R U U void CC7MD3*D g>>7n4'i#'opt=? T VV ;7D7> 8dd your #ontro notifi#ation 'and er #ode 'ere s&it#'=mCmsgd g.mCiopt? T #ase 1>mCresFD1st opt se e#tedDR brea)R #ase 1>mCresFD2nd opt se e#tedDR brea)R #ase 2>mCresFD!rd opt se e#tedDR brea)R #ase !>mCresFD$t' opt se e#tedDR brea)R U GpdateData=F83"5?R U

.
SAMPLE OUTPUT,

:;ype te6t<

RESULT, ;'us t'e 2C@@ Program to #reate #ommon and #ustom dia og is deve oped and e6e#uted su##essfu y.

E-, 14.Mo$ele%% 0ialog *ox Crea"ion


Aim, ;o &rite a 2C@@ program to disp ay t'e te6t on mode ess dia og bo6 Logi!al 0e%!ri "ion, ;'e program starts &it' ob,e#t #reation. 8fter initia iAing t'e instan#e, t'e user #reated &indo& is assigned as main &indo&. Gsing "'o& &indo& option pro,e#t user #reated &indo&. Gsing resour#es option #reate a Mode ess dia og bo6 & atta#' it to t'e user #reated &indo&. Algori"#m, 1. "tart t'e pro#ess 2. Create a dia og bo6 using +DDCD+837*1 and add t'e items in it !. ;'e #reation of t'e dia og bo6 #an be done &it' t'e 'e p of CDia og #reating an instan#e to it. $. 8 o#ate memory to t'e #reated instan#e %. Ca t'e #reate met'od =#reation of instan#e? on t'e event H.uttonDo&n (. "top t'e pro#ess So&r!e Co$e, Sin# udeMaf6&in.'N Sin# udeMaf6d gs.'N Sin# ude Dresour#e.'D # ass myd g>pub i# CDia og T pub i#> myd g=?>CDia og=? T U pub i#> .773 7n+nitDia og=? T return ;HG5R U void 7n7K=? :;ype te6t<

T 5ndDia og=;HG5?R U void 7nCan#e =? T 5ndDia og=F83"5?R U D5C38H5CM5""8*5CM8P=? UR .5*+OCM5""8*5CM8P=myd g,CDia og? 7OCC7MM8OD=+DCCC+HC35, 7nCir# e? 7OCC7MM8OD=+DCC"JG8H5, 7n"Buare? 5ODCM5""8*5CM8P=? # ass my&in>pub i# CFrame4nd T pub i#> my&in=? T Create=1,DMFC 4+OD74D?R U void 7nH.uttonDo&n= ? T CDia og Id gR d g F ne& myd g=?R d g-NCreate=+DDCD+837*1?R d g-N"'o&4indo&=1?R U D5C38H5CM5""8*5CM8P=? UR .5*+OCM5""8*5CM8P=my&in,CFrame4nd? 7OC4MCH.G;;7OD74O=? 5ODCM5""8*5CM8P=? # ass myapp>pub i# C4in8pp T pub i#> .773 +nit+nstan#e=? T my&in IpR pFne& my&in=?R mCpMain4ndFpR p-N"'o&4indo&="4C"P74O7HM83?R return trueR U UR myapp 8R

:;ype te6t<

O&" &",

RESULT, ;'us t'e program to disp ay t'e te6t on mode ess dia og bo6 'as been su##essfu y e6e#uted and verified

:;ype te6t<

E-,15. S0I SERIALIFATION Aim, ;o &rite a 2C@@ program to imp ement "D+ "eria iAation Logi!al 0e%!ri "ion, Pro#ess of saving and restoring ob,e#ts is #a ed seria iAation. +mp ement seria iAation for "D+ app i#ations Algori"#m, 1. "tart t'e pro#ess 2. Create an ob,e#t for myapp and invo)e a met'od +nit+nstan#e= ? &'i#' #a s my&in= ?. !. 4rite a met'od to &rite into a fi e> 7n4rite= ? in my&in # ass. $. 4rite a met'od to read from a fi e > 7nHead = ? in t'e # ass my&in. %. Map t'ese met'ods to t'e members #reated. (. "top t'e pro#ess So&r!e Co$e, VV sdiDo#.#pp > imp ementation of t'e C"diDo# # ass Sin# ude Dstdaf6.'D Sin# ude Dsdi.'D Sin# ude DsdiDo#.'D Sifdef CD5.G* Sdefine ne& D5.G*CO54 Sundef ;P+"CF+35 stati# #'ar ;P+"CF+35:< F CCF+35CCR Sendif VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV VV C"diDo# +MP35M5O;CDEOCH58;5=C"diDo#, CDo#ument? .5*+OCM5""8*5CM8P=C"diDo#, CDo#ument? VVTT8F9CM"*CM8P=C"diDo#? VV O7;5 - t'e C ass4iAard &i add and remove mapping ma#ros 'ere. VV D7 O7; 5D+; &'at you see in t'ese b o#)s of generated #odeZ VVUU8F9CM"*CM8P 5ODCM5""8*5CM8P=? VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV VV C"diDo# #onstru#tionVdestru#tion C"diDo#>>C"diDo#=? T VV ;7D7> add one-time #onstru#tion #ode 'ere U :;ype te6t<

C"diDo#>>]C"diDo#=? T U .773 C"diDo#>>7nOe&Do#ument=? T if =ZCDo#ument>>7nOe&Do#ument=?? return F83"5R d6F%1R dyF%1R VV ;7D7> add reinitia iAation #ode 'ere VV ="D+ do#uments &i reuse t'is do#ument? return ;HG5R U VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV VV C"diDo# seria iAation void C"diDo#>>"eria iAe=C8r#'ive& ar? T if =ar.+s"toring=?? T VV ;7D7> add storing #ode 'ere arMMd6MMdyR VVarNNd6NNdyR U e se T VV ;7D7> add oading #ode 'ere VVarMMd6MMdyR arNNd6NNdyR U U VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV VV C"diDo# diagnosti#s Sifdef CD5.G* void C"diDo#>>8ssert2a id=? #onst T CDo#ument>>8ssert2a id=?R U void C"diDo#>>Dump=CDumpConte6t& d#? #onst T CDo#ument>>Dump=d#?R U Sendif VVCD5.G* VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV VV C"diDo# #ommands

:;ype te6t<

O&" &",

RESULT, ;'us t'e program to imp ement "D+ "eria iAation 'as been su##essfu y e6e#uted and verified

:;ype te6t<

E-,17. M0I SERILAIFATION Aim, ;o &rite a 2C@@ program to imp ement MD+ seria iAation Logi!al 0e%!ri "ion, Pro#ess of saving and restoring ob,e#ts is #a ed seria iAation. +mp ement seria iAation for MD+ app i#ations Algori"#m, 1. "tart t'e pro#ess 2. "e e#t MFC app&iAard =56e? and se e#t mu tip e do#ument in t'at. !. *ive ne6t for furt'er steps and fina y # i#) finis' button $. Create menu for read and &rite %. For bot' read and &rite go to t'e # ass &iAard, se e#t #ommand in t'at and &rite t'e reBuired #odings (. ;'e do#ument fi e &i be avai ab e in t'e o#a spa#e &'ere &e 'ave started. -. 56e#ute t'e program /. "top t'e pro#ess So&r!e Co$e, VV seria iAationmdi2ie&.#pp > imp ementation of t'e C"eria iAationmdi2ie& # ass Sin# ude Dstdaf6.'D Sin# ude Dseria iAationmdi.'D Sin# ude Dseria iAationmdiDo#.'D Sin# ude Dseria iAationmdi2ie&.'D Sifdef CD5.G* Sdefine ne& D5.G*CO54 Sundef ;P+"CF+35 stati# #'ar ;P+"CF+35:< F CCF+35CCR Sendif VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV VV C"eria iAationmdi2ie& +MP35M5O;CDEOCH58;5=C"eria iAationmdi2ie&, C2ie&? .5*+OCM5""8*5CM8P=C"eria iAationmdi2ie&, C2ie&? VVTT8F9CM"*CM8P=C"eria iAationmdi2ie&? 7OCC7MM8OD=+DC4H+;5, 7n4rite? 7OCC7MM8OD=+DCH58D, 7nHead? VVUU8F9CM"*CM8P VV "tandard printing #ommands 7OCC7MM8OD=+DCF+35CPH+O;, C2ie&>>7nFi ePrint? 7OCC7MM8OD=+DCF+35CPH+O;CD+H5C;, C2ie&>>7nFi ePrint? :;ype te6t<

7OCC7MM8OD=+DCF+35CPH+O;CPH52+54, C2ie&>>7nFi ePrintPrevie&? 5ODCM5""8*5CM8P=? VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV VV C"eria iAationmdi2ie& #onstru#tionVdestru#tion C"eria iAationmdi2ie&>>C"eria iAationmdi2ie&=? T VV ;7D7> add #onstru#tion #ode 'ere U C"eria iAationmdi2ie&>>]C"eria iAationmdi2ie&=? T U .773 C"eria iAationmdi2ie&>>PreCreate4indo&=CH58;5";HGC;& #s? T VV ;7D7> Modify t'e 4indo& # ass or sty es 'ere by modifying VV t'e CH58;5";HGC; #s return C2ie&>>PreCreate4indo&=#s?R U VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV VV C"eria iAationmdi2ie& dra&ing void C"eria iAationmdi2ie&>>7nDra&=CDCI pDC? T C"eria iAationmdiDo#I pDo# F *etDo#ument=?R 8""5H;C283+D=pDo#?R VV ;7D7> add dra& #ode for native data 'ere U VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV VV C"eria iAationmdi2ie& printing .773 C"eria iAationmdi2ie&>>7nPreparePrinting=CPrint+nfoI p+nfo? T VV defau t preparation return DoPreparePrinting=p+nfo?R U void C"eria iAationmdi2ie&>>7n.eginPrinting=CDCI VIpDCIV, CPrint+nfoI VIp+nfoIV? T VV ;7D7> add e6tra initia iAation before printing U void C"eria iAationmdi2ie&>>7n5ndPrinting=CDCI VIpDCIV, CPrint+nfoI VIp+nfoIV? T VV ;7D7> add # eanup after printing U VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV VV C"eria iAationmdi2ie& diagnosti#s Sifdef CD5.G* void C"eria iAationmdi2ie&>>8ssert2a id=? #onst T C2ie&>>8ssert2a id=?R :;ype te6t<

U void C"eria iAationmdi2ie&>>Dump=CDumpConte6t& d#? #onst T C2ie&>>Dump=d#?R U C"eria iAationmdiDo#I C"eria iAationmdi2ie&>>*etDo#ument=? VV non-debug version is in ine T 8""5H;=mCpDo#ument-N+sKind7f=HGO;+M5CC38""=C"eria iAationmdiDo#???R return =C"eria iAationmdiDo#I?mCpDo#umentR U Sendif VVCD5.G* VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV VV C"eria iAationmdi2ie& message 'and ers void C"eria iAationmdi2ie&>>7n4rite=? T CFi e IfR f F ne& CFi eR f-N7pen=DD>QQmdi.t6tD, CFi e>>modeCreate\CFi e >>mode4rite?R f-N4rite=D4e #ome to 2C@@D, 1%?R f-NC ose=?R Message.o6=DData 4rittenD, DFi e 4riteD?R U void C"eria iAationmdi2ie&>>7nHead=? T #'ar 6:111<R CFi e IfR f F ne& CFi eR f-N7pen=DD>QQmdi.t6tD, CFi e>>modeHead?R D47HD siAe F f-N*et3engt'=?R f-NHead=6, siAe?R f-NC ose=?R CC ientDC d#=t'is?R d#.;e6t7ut=%1,%1, 6, siAe?R U

:;ype te6t<

O&" &",

RESULT, ;'us t'e program to imp ement MD+ seria iAation 'as been su##essfu y e6e#uted and verified

:;ype te6t<

E-, NO.19 SLI0ER CONTROL Aim, ;o &rite a 2isua C@@ program for #reating a " ider Contro using &in!2 app i#ation. Logi!al 0e%!ri "ion, ;'e program starts &it' ob,e#t #reation. 8fter initia iAing t'e instan#e, t'e user #reated &indo& is assigned as main &indo&. Gsing "'o& &indo& option pro,e#t user #reated &indo&. Algori"#m, 1. "tart t'e Pro#ess 2. Create an ob,e#t for an # ass &'i#' in'erits C4in8pp !. ;'e ob,e#t a##ess +nit+nstan#e=? fun#tion $. Create a pointer ob,e#t for t'e # ass &'i#' in'erits CFrame4indo& by a o#ating t'e memory to t'e ob,e#t %. "'o& t'e #reated &indo& using "4C"P74O7HM83 (. "top t'e pro#ess So&r!e Co$e, Sin# udeMaf6&in.'N Sin# udeMaf6#mn.'N # ass myframe>pub i# CFrame4nd T private> C" iderCtr s iR C.utton grR pub i#> myframe=? T C"tring my&indo&# assR my&indo&# assF8f6Hegister4ndC ass= C"C2H5DH84\C"CPH5DH84,1, =P.HG"P?>>*et"to#)7b,e#t=3;*H8EC.HG"P?,1?R Create=my&indo&# ass,D" ider Contro D?R U int 7nCreate=3PCH58;5";HGC; +? T CFrame4nd>>7nCreate=+?R gr.Create=D"3+D5H D+"P38ED,4"CCP+3D\4"C2+"+.35\ ."C*H7GP.79,CHe#t=!1,!1,!11,111?,t'is,1?R s i.Create=4"CCP+3D\4"C2+"+.35\;."CP7H[\;."C8G;7;+CK"\ ;."C.7;;7M\;."C5O8.35"53H8O*5,CHe#t=!%,%1,!1%,01?,t'is,2?R s i."etHange=1,/?R s i."etPos=2?R :;ype te6t<

s i."et"e e#tion=1,2?R s i."etPage"iAe=!?R return 1R U void 7nP"#ro =G+O; #ode,G+O; pos,C"#ro .ar Is#ro ? T s&it#'=#ode? T #ase ;.C3+O5GP> #ase ;.C3+O5D74O> #ase ;.CP8*5GP> #ase ;.CP8*5D74O> #ase ;.C;7P> #ase ;.C.7;;7M> posFs i.*etPos=?R s i."et"e e#tion=1,pos?R s i."et;i#=pos?R brea)R #ase ;.C;PGM.P7"+;+7O> s i."et"e e#tion=1,pos?R s i."et;i#=pos?R brea)R #ase ;.C;PGM.;H8CK> s i."et"e e#tion=1,pos?R s i."et;i#=pos?R brea)R U U D5C38H5CM5""8*5CM8P=? UR .5*+OCM5""8*5CM8P=myframe,CFrame4nd? 7OC4MCCH58;5=? 7OC4MCP"CH733=? 5ODCM5""8*5CM8P=? # ass myapp>pub i# C4in8pp T pub i#> int +nit+nstan#e=? T myframe IpR pFne& myframeR p-N"'o&4indo&=!?R mCpMain4ndFpR return 1R U UR myapp aR O&" &", :;ype te6t<

RESULT, ;'us t'e program for #reating a " ider Contro 'as been su##essfu y e6e#uted and verified

E-, NO.1:.TREE VIE8 CREATION :;ype te6t<

Aim, ;o &rite a 2isua C@@ program for #reating a ;ree 2ie& Contro using &in!2 app i#ation. Logi!al 0e%!ri "ion, ;'e program starts &it' ob,e#t #reation. 8fter initia iAing t'e instan#e, t'e user #reated &indo& is assigned as main &indo&. Gsing "'o& &indo& option pro,e#t user #reated &indo&. Algori"#m, 1. "tart t'e Pro#ess 2. Create an ob,e#t for an # ass &'i#' in'erits C4in8pp !. ;'e ob,e#t a##ess +nit+nstan#e=? fun#tion $. Create a pointer ob,e#t for t'e # ass &'i#' in'erits CFrame4indo& by a o#ating t'e memory to t'e ob,e#t %. "'o& t'e #reated &indo& using "4C"P74O7HM83 (. "top t'e pro#ess So&r!e Co$e, Sin# udeMaf6&in.'N Sin# udeMaf6#mn.'N # ass myframe>pub i# CFrame4nd T private> C;reeCtr treeR pub i#> myframe=? T Create=1,D;ree vie& #ontro D?R U int 7nCreate=3PCH58;5";HGC; +? T P;H55+;5M ang,opersys,#,#pp,,avaR CFrame4nd>>7nCreate=+?R tree.Create=4"CCP+3D\4"C2+"+.35\4"C.7HD5H\;2"CP8"3+O5"\ ;2"C3+O5"8;H77;\;2"CP8".G;;7O"\ ;2"C"P74"538348E",CHe#t=!1,!1,!11,!%1?,t'is,1?R angFtree.+nsert+tem=DComputer anguagesD,;2+CH77;,;2+C"7H;?R #Ftree.+nsert+tem=DCD, ang,;2+C"7H;?R tree.+nsert+tem=D;CD,#?R tree.+nsert+tem=DJCD,#?R tree.+nsert+tem=DM"CD,#?R #ppFtree.+nsert+tem=D#@@D, ang,;2+C"7H;?R tree.+nsert+tem=D2C@@D,#pp?R tree.+nsert+tem=D.or and #@@D,#pp?R ,avaFtree.+nsert+tem=D,avaD, ang,;2+C"7H;?R tree.+nsert+tem=D2^@@D,,ava?R :;ype te6t<

tree.+nsert+tem=D"ymante# #afeD,,ava?R tree.+nsert+tem=D"un ^DKD,,ava?R opersysFtree.+nsert+tem=Doperating systemsD,;2+CH77;,;2+C"7H;?R tree.+nsert+tem=D&in !.1D,opersys?R tree.+nsert+tem=D&in 0%D,opersys?R tree.+nsert+tem=D&in O;D,opersys?R return 1R U int 7nOotify=4P8H8M &,3P8H8M +,3H5"G3; Ir? T P;H55+;5M 'R C"tring strR C4nd>>7nOotify=&,+,r?R OMC;H552+54 IpF=OMC;H552+54 I?+R if=p-N'dr.#odeFF;2OC"53CP8O*5D? T 'Ftree.*et"e e#ted+tem=?R strFtree.*et+tem;e6t='?R Message.o6=str,Dyou 'ave se e#tedD?R U return 1R U D5C38H5CM5""8*5CM8P=? UR .5*+OCM5""8*5CM8P=myframe,CFrame4nd? 7OC4MCCH58;5=? 5ODCM5""8*5CM8P=? # ass myapp>pub i# C4in8pp T pub i#> int +nit+nstan#e=? T myframe IpR pFne& myframeR p-N"'o&4indo&=!?R mCpMain4ndFpR return 1R U UR myapp aR

O&" &",
:;ype te6t<

RESULT, ;'us t'e program for tree vie& #ontro 'as been su##essfu y e6e#uted and verified

:;ype te6t<

Ex. No, 1;.PROGRESS CONTROL CREATION


Aim, ;o &rite a 2isua C@@ program for #reating a Progress Contro Creation using &in!2 app i#ation. Logi!al 0e%!ri "ion, ;'e program starts &it' ob,e#t #reation. 8fter initia iAing t'e instan#e, t'e user #reated &indo& is assigned as main &indo&. Gsing "'o& &indo& option pro,e#t user #reated &indo&. Algori"#m, 1."tart t'e Pro#ess 2.Create an ob,e#t for an # ass &'i#' in'erits C4in8pp !.;'e ob,e#t a##ess +nit+nstan#e=? fun#tion $.Create a pointer ob,e#t for t'e # ass &'i#' in'erits CFrame4indo& by a o#ating t'e memory to t'e ob,e#t %."'o& t'e #reated &indo& using "4C"P74O7HM83 (."top t'e pro#ess So&r!e Co$e, Sin# udeMaf6&in.'N Sin# udeMaf6#mn.'N Sin# ude Dresour#e.'D # ass sortdia og>pub i# CDia og T private> C"tring fnameR Pub i#> sortdia og=int n?>CDia og=n? T fnameFD5nter fi e to be sortedDR U void DoDta56#'ange=CData56#'ange Ip? T DD9C;e6t=p,+DCC5D+;1,fname?R U void 7n7)=? T C"tring str:111<,tempR C"tdioFi e fpR CProgressCtr I#R GpdateData=;HG5?R #F=CProgressCtr I?*etD g+tem=+DCCPH7*H5""1?R #-N"et"tep=%?R if=fp.7pen=fname,CFi e>>modeHead4rite?? :;ype te6t<

T int #ountF1R fp."ee);o.egin=?R &'i e=fp.Head"tring =str:#ount<?ZFOG33? #ount@@R for=int ,F1R,M#ountR,@@? T for=int )F,@1R)M#ountR)@@? T if=str:,<Nstr:)<? T tempFstr:,<R str:,<Fstr:)<R str:)<FtempR U U #-N"tep+t=?R " eep=111?R U fp."ee);o.egin=?R for=int iF1RiM#ountRi@@? T fp.4rite"tring=str:i<?R U fp.C ose=?R U e se Message.o6=fname,D#annot open fi eD?R 5ndDia og=+D7K?R U UR # ass #opydia og>pub i# CDia og T private> C"tring sour#e,targetR pub i#> #opydia og=int n?>CDia og=n? T sour#eFDenter sour#e fi e nameDR targetFDenter target fi e nameDR U void DoData56#'ange=CData56#'ange Ip? T DD9C;e6t=p,+DCC5D+;1,sour#e?R DD9C;e6t=p,+DCC5D+;2,target?R U void 7n7)=? T :;ype te6t<

C8nimateCtr I#R C"tdioFi e fs,ftR #'ar str:211<R GpdateData=?R #F=C8nimateCtr I? *etD g+tem=+DCC8O+M8;51?R #-N7pen=Ddi o.aviD?R #-NP ay=1,-1,-1?R if=fs.7pen=sour#e,CFi e>>modeHead?FF1? T Message.o6=D#annot open sour#e fi eD,Dfi e errorD?R returnR U if=fs.7pen=target,CFi e>>modeCreate\CFi e>>mode4rite?FF1? T Message.o6=D#annot open sour#e fi eD,Dfi e errorD?R returnR U &'i e=fs.Head"tring=str,100?ZFOG33? T ft.4rite"tring=str?R " eep=111?R U fs.C ose=?R ft.C ose=?R #-N"top=?R #-NC ose=?R 5ndDia og=1?R U UR # ass myframe>pub i# CFrame4nd T pub i#> myframe=? T Create=1,Dprogress bar and animation #ontro D,4"C725H38PP5D4+OD74,re#tDefau t,1?R U void sort=? T sortdia og IdR dF ne& sortdia og=+DDCD+837*1?R d-NDoModa =?R U void #opy=? T :;ype te6t<

#opydia og IdR dFne& #opydia og=+DDCD+837*2?R d-NDoModa =?R U D5C38H5CM5""8*5CM8P=? UR .5*+OCM5""8*5CM8P=myframe,CFrame4nd? 7OCC7MM8OD=111,sort? 7OCC7MM8OD=112,#opy? 5ODCM5""8*5CM8P=? # ass myapp>pub i# C4in8pp T pub i#> int +nit+nstan#e=? T myframe IpR pFne& myframeR p-N"'o&4indo&=!?R mCpMain4ndFpR return 1R U UR myapp aR

O&" &",

:;ype te6t<

RESULT, ;'us t'e program for #reating a Progress Contro 'as been su##essfu y e6e#uted and verified

Ex.No, .< S li""er Vie3 Con"rol


:;ype te6t<

Aim, ;o &rite a 2isua C@@ program for #reating a "p itter 2ie& Contro using &in!2 app i#ation. Logi!al 0e%!ri "ion, ;'e program starts &it' ob,e#t #reation. 8fter initia iAing t'e instan#e, t'e user #reated &indo& is assigned as main &indo&. Gsing "'o& &indo& option pro,e#t user #reated &indo&. Algori"#m, 1. "tart t'e Pro#ess 2.Create an ob,e#t for an # ass &'i#' in'erits C4in8pp !. ;'e ob,e#t a##ess +nit+nstan#e =? fun#tion $. Create a pointer ob,e#t for t'e # ass &'i#' in'erits CFrame4indo& by a o#ating t'e memory to t'e ob,e#t %. "'o& t'e #reated &indo& using "4C"P74O7HM83 (. "top t'e pro#ess So&r!e Co$e, VV "p itterDo#.#pp > imp ementation of t'e C"p itterDo# # ass VV Sin# ude Dstdaf6.'D Sin# ude D"p itter.'D Sin# ude D"p itterDo#.'D Sifdef CD5.G* Sdefine ne& D5.G*CO54 Sundef ;P+"CF+35 stati# #'ar ;P+"CF+35:< F CCF+35CCR Sendif VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV VV C"p itterDo# +MP35M5O;CDEOCH58;5=C"p itterDo#, CDo#ument? .5*+OCM5""8*5CM8P=C"p itterDo#, CDo#ument? VVTT8F9CM"*CM8P=C"p itterDo#? VV O7;5 - t'e C ass4iAard &i add and remove mapping ma#ros 'ere. VV D7 O7; 5D+; &'at you see in t'ese b o#)s of generated #odeZ VVUU8F9CM"*CM8P 5ODCM5""8*5CM8P=? VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV VV C"p itterDo# #onstru#tionVdestru#tion C"p itterDo#>>C"p itterDo#=? T VV ;7D7> add one-time #onstru#tion #ode 'ere U :;ype te6t<

C"p itterDo#>>]C"p itterDo#=? T U .773 C"p itterDo#>>7nOe&Do#ument=? T if =ZCDo#ument>>7nOe&Do#ument=?? return F83"5R VV ;7D7> add reinitia iAation #ode 'ere VV ="D+ do#uments &i reuse t'is do#ument? return ;HG5R U VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV VV C"p itterDo# seria iAation void C"p itterDo#>>"eria iAe=C8r#'ive& ar? T VV C5dit2ie& #ontains an edit #ontro &'i#' 'and es a seria iAation ==C5dit2ie&I?mCvie&3ist.*etPead=??-N"eria iAeHa&=ar?R U VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV VV C"p itterDo# diagnosti#s Sifdef CD5.G* void C"p itterDo#>>8ssert2a id=? #onst T CDo#ument>>8ssert2a id=?R U void C"p itterDo#>>Dump=CDumpConte6t& d#? #onst T CDo#ument>>Dump=d#?R U Sendif VVCD5.G* VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV VV C"p itterDo# #ommands

O&" &",

:;ype te6t<

RESULT, ;'us t'e program for #reating a "p itter 2ie& Contro 'as been su##essfu y e6e#uted and verified

:;ype te6t<

E-, .1.Crea"ing 0LL an$ U%ing i"


Aim,
;o &rite a 2C@@ program to deve op D33 and e6port t'e fun#tion using MFC =.d ? and use t'e same fun#tion in t'e # ient program using MFC =.e6e?.

Logi!al 0e%!ri "ion,


D33 is a fi e on dis) &it' a D33 e6tension #onsisting of g oba data, #ompi ed fun#tions, and resour#es t'at be#omes part of our pro#ess. +t is #ompi ed to oad at a preferred base address, and if t'ere is no #onf i#t &it' ot'er D33s, t'e fi e gets mapped to t'e same virtua address in our pro#ess. ;'e D33 #onsists of e6ported fun#tion, and t'e # ient program imports t'ose e6ported fun#tions. 4indo&s mat#'es up t'e imports and e6ports &'en it oads t'e D33. C asses are bui d-time modu ar D33s are runtime modu ar

C ient programs #an oad and in) our D33 very Bui#) y &'en t'ey run. ;'is program is to #reate "ayPe o= ? in t'e D33 and e6ported t'is fun#tion to any # ient program to use it. 8 so t'is D33 is in# uded in t'e # ient program to use t'e "ayPe o= ?.

S"e % "o *&il$ "#e M)0ll an$ Te%"0ll a


0LL Ser+er = M)0ll.$%3

li!a"ion,

1. Hun 2C@@ MFC 8pp4iAard to #reate =.d ?..GM)0ll 2. "e e#t Hegu ar D33 using "'ared MFC D33 and # i#) finis'. !. *oto C ass 2ie& and rig't # i#) t'e MyD # ass and #'oose Ne3 Cla%%. $. Oo& #'oose t'e # ass type to be t'e *eneri# C ass and type t'e # ass name as CMyC ass t'en # i#) 7K. %. ;'en add member fun#tion to t'e CMyC ass by rig't # i#)ing and type, a. fun#tion type as CS"ring b. fun#tion name as Sa)1ello@CS"ring %"rNameAB #. a##ess type is &*li! (. 8dd t'e fun#tion definition in MyClass.cpp
CString CMyClass:: SayHello(CString strName) {

:;ype te6t<

return Hello + strName; }

-. ;o #a t'e D33 fun#tion from an e6terna app i#ation &e 'ave to prefi6 t'e fun#tion &it' t'e signature in MyClass.h &it' HI$e!l% e!@$llex or"AJ. 8dd t'e fo o&ing *ol$'a!e #ode to t'e fo o&ing statements in MyClass.h fi e, pub i#>
_declspec(dllexport) CString SayHello(CSTring strName); _declspec(dllexport) CMyClass(); _declspec(dllexport) virtual ~CMyClass();

/. Compi e t'e #ode &it'out e6e#uting. 0LL Clien" = Te%"0ll.$%3 1. Hun t'e 2C@@ MFC 8pp4iAard=.e6e? to deve op a dia og based app i#ation ..GTe%"$ll.$%3 2. ;'e resour#e editor &i be enab ed on#e finis'ing t'e pro,e#t and add one stati# #ontro , one edit #ontro and one button #ontro . !. 8dd t'e id for t'e edit #ontro I0CINAME and add t'e member variab e as mI%Name and type as CS"ring by using t'e # ass &iAard. $. Gse t'e # ass &iAard to map t'e message OnO( fun#tion for I0O/ in t'e TestDllDlg # ass. %. Oo& edit t'e #ode on TestDllDlg.cpp
Void CTestDllDlg:: n !() { CMyClass objMyClass; UpdateData(true); CStr n! str " objMyClass#SayHello(m_sName); $%xMessa!e&ox(str); }

(. Oo& add t'e entire pat' of t'e MyD server 'eader fi e in Te%"0ll0lg.#
"in#lude $%:&%'er#ise&MyDll&MyClass()*

-. C i#) t'e pro,e#t menu and se e#t t'e settings and # i#) on t'e in) tab and type t'e entire pat' of t'e MyDll.lib fi e in t'e O*Ke!"LLi*rar) Mo$&le% te6t bo6es as,
%:&%'er#ise&MyDll&De+ug&MyDll(li+

/. Oo& #opy t'e MyDll.dll in t'e MyD Debug fo der into t'e ;estD fo der. :;ype te6t<

0. .ui d t'e pro,e#t and e6e#ute it.

O&" &",

RESULT, ;'us t'e program for #reating D33 'as been su##essfu y e6e#uted and verified

:;ype te6t<

E-,... 8INSOC/ CONTROL = C1AT PROGRAM AIM, ;o &rite a visua basi# program to perform #'at using 4+O"7CK Contro . ALGORIT1M, 1. 7pen a ne& standard e6e pro,e#t and forms 1 and 2 respe#tive y. 2. P a#e 4in"o#) #ontro in bot' forms :Form 1 C ient, Form 2 "erver< !. 8dd t'e ot'er reBuired #ontro s i)e te6t bo6, #ommand button, abe in t'e forms and ad,ust t'e properties a##ording y. $. 8ssign t'e +P address as +nterna 3oop ba#) address :12-.1.1.1< and port number as 12!$% in bot' # ient and server form. %. "erver is a &ays istening for # ients to get #onne#ted to. :Press isten button< (. C ient #onne#tion &it' server gets estab is'ed by pressing C7OO5C; button. -. 8fter t'is 'ands'a)e, t&o &ay #ommuni#ation ensues bet&een C3+5O; 8OD "5H25H :Press "end button<. /. 56e#ute t'e forms and &itness t'e 2 &ay #'at. PROGRAM, C3+5O;> Private "ub CMDC7OO5C;CC i#)=? main.HemotePost F ;e6t1.;e6t main.HemotePort F ;e6t2.;e6t main.Conne#t 5nd "ub Private "ub CMD"5O;CC i#)=? main."endData ;e6t$.;e6t 5nd "ub Private "ub Command1CC i#)=? 5nd 5nd "ub Private "ub FormC3oad=? Form2."'o& 5nd "ub Private "ub 4inso#)1C5rror=.y2a Oumber 8s +nteger, Des#ription 8s "tring, .y2a "#ode 8s 3ong, .y2a "our#e 8s "tring, .y2a Pe pFi e 8s "tring, .y2a Pe pConte6t 8s 3ong, Can#e Disp ay 8s .oo ean? 5nd "ub Private "ub mainCData8rriva =.y2a bytes;ota 8s 3ong? Dim strdata 8s "tring main.*etData strdata, vb"tring :;ype te6t<

;e6t!.;e6t F ;e6t!.;e6t & strdata & vbCr3f 5nd "ub "5H25H> Private "ub CMD3+";5OCC i#)=? main.3o#a Port F ;e6t1.;e6t main.3isten 5nd "ub Private "ub CMD"5ODCC i#)=? main."endData ;e6t2.;e6t 5nd "ub Private "ub Command1CC i#)=? 5nd 5nd "ub Private "ub FormC3oad=? 5nd "ub Private "ub mainCConne#tionHeBuest=.y2a reBuest+D 8s 3ong? +f main."tate MN s#)C osed ;'en main.C ose 5nd +f main.8##ept reBuest+D ;e6t!.;e6t F ;e6t!.;e6t & Da##epted #onne#tion from D & main.HemotePost+P & vbCr3f 5nd "ub Private "ub mainCData8rriva =.y2a bytes;ota 8s 3ong? Dim strdata 8s "tring main.*etData strdata, vb"tring ;e6t!.;e6t F ;e6t!.;e6t & strdata & vbCr3f 5nd "ub

:;ype te6t<

OUTPUT,

RESULT, ;'us t'e #'at program in 2. using 4inso#) #ontro 'as been e6e#uted su##essfu y.

E- NO..2
:;ype te6t<

0a"a A!!e%% "#ro&g# O0BC

Aim,
;o &rite a 2C@@ program to a##ess t'e "tudent database t'roug' MFC 7D.C.

Logi!al 0e%!ri "ion,


;'e program iso ates t'e database a##ess #ode from user interfa#e #ode so t'at &e #an see 'o& to add 7D.C database #apabi ity to any MFC app i#ation. Pere C ass4iAard to generate a CRecordset # ass, but &onYt be using t'e CRecordView # ass t'at 8pp4iAard generates &'en you as) for a database vie& app i#ation. ;'is app i#ation is fair y simp e. +t disp ays t'e ro&s from t'e student database tab e in a s#ro ing vie&. ;'e student tab e is part of t'e "tudent Oame3ist database t'atYs in# uded &it' 2isua C@@.

S"e % 'or *&il$ing "#e S"&$en" a

li!a"ion,

1. Crea"e "#e $a"a*a%e %"&$.m$* &%ing MS A!!e%%. 2. R&n "#e O0BC 0a"a So&r!e A$mini%"ra"or "o in%"all "#e S"&$en" Regi%"ra"ion $a"a %o&r!e. a. C i#) t'e 7D.C i#on in t'e 4indo&s Contro Pane . b. C i#) t'e Drivers tab to see &'et'er t'e Mi#rosoft 8##ess driver is avai ab e. #. C i#) t'e 8dd button =t'e 8dd button is on t'e Gser D"O tab?, d. #'oose Mi#rosoft 8##ess Driver in t'e 8dd Data "our#e dia og bo6 =se e#t t'e Mi#rosoft 8##ess Driver in t'e Create Oe& Data "our#e dia og bo6 and # i#) t'e Finis' button?, e. 8nd fi in t'e 7D.C Mi#rosoft 8##ess "etup dia og bo6.

:;ype te6t<

f. !. a. b.

"et t'e database to point to stud.mdb using t'e "e e#t button. Fina y, # i#) t'e 7K button. R&n A 8iMar$ "o ro$&!e G+! GS"&$en".

"pe#ify an "D+ app i#ation ="tep 1 dia og bo6?. "e e#t t'e Peader Fi es 7n y option from t'e 8pp4iAard "tep 2 dia og bo6, as s'o&n 'ere. #. "e e#t CScrollView as t'e vie&Ys # ass type ="tep ( dia og bo6?. $. U%e Cla%%8iMar$ "o !rea"e "#e CStudentSet re!or$%e" !la%%. a. C'oose Oe& from t'e 8dd C ass menu, and t'en fi in t'e Oe& C ass dia og bo6 as s'o&n 'ere.

5.

Sele!" "#e S"&$en" Regi%"ra"ion $a"a*a%eN% S"&$en" "a*le 'or "#e CStudentSet !la%%. a. 4'en you # i#) t'e 7K button in t'e Oe& C ass dia og bo6, C ass4iAard disp ays t'e Database 7ptions dia og bo6. b. "e e#t t'e "tudent Hegistration data sour#e, and se e#t t'e Dynaset option as s'o&n 'ere.

:;ype te6t<

#.

8fter you se e#t t'e data sour#e, C ass4iAard prompts you to se e#t a tab e. "e e#t "tudent, as s'o&n 'ere.

(. a. b.

Examine "#e $a"a mem*er% "#a" Cla%%8iMar$ genera"e%.

C i#) on t'e Member 2ariab es tab for t'e ne& y generated CStudentSet # ass. C ass4iAard s'ou d 'ave generated data members based on student #o umn names. -. 0e!lare an em*e$$e$ re!or$%e" o*Ke!" in S"&$en"0o!.#. a. 8dd t'e fo o&ing pub i# data member in t'e CStudentDoc # ass de# aration>
CStudentSet m_StudentSet;

/. E$i" "#e S"&$en"0o!.! 8dd t'e ine

'ile.

#include "StudentSet.h"

,ust before t'e ine :;ype te6t<

#include "StudentDoc.h"

0. 0e!lare a re!or$%e" oin"er in S"&$en"Vie3.#. a. 8dd t'e fo o&ing private data member in t'e CStudentView # ass de# aration>
CStudentSet* m_pSet;

11. E$i" "#e OnDraw an$ OnInitialUpdate '&n!"ion% in S"&$en"Vie3.! a. 8dd t'e fo o&ing bo dfa#e #ode>
void CStudentView::OnDraw(CDC* pDC) { TEXTMETRIC tm; pDC->GetTextMet ic!"#tm$; int n%ine&ei'ht(tm.tm&ei'ht)tm.tmExte n*l%e*din'; C+,int pText"-.-$;

int / ( -; CSt in' !t ; i0 "m_pSet->I!123"$$ 4 55 detect! empt/ ec, d!et etu n; 6 m_pSet->M,7e3i !t"$; 55 0*il! i0 ec, d!et i! empt/ 8hile "9m_pSet->I!E23"$$ 4 !t .3, m*t"":ld". m_pSet->m_Re';,$; pDC->Text2ut"pText.x. pText./. !t $; pDC->Text2ut"pText.x)<---. pText./. m_pSet->m_;*me$; m_pSet->M,7e;ext"$; pText./ -( n%ine&ei'ht; 6 } void CStudentView::OnInitial pdate() { CScrollView::OnInitial pdate()! CSi"e #i"e$otal(%&&&' (&)&&)! SetSc ,llSi=e!"MM_&IE;G%IS&. !i=eT,t*l$; m_pSet ( #GetD,cument"$->m_StudentSet; 55 Remem>e th*t d,cument!57ie8! * e eu!ed in SDI *pplic*ti,n!9 i0 "m_pSet->I!2pen"$$ 4 m_pSet->Cl,!e"$; 6 m_pSet->2pen"$; }

b.

8 so in "tudent2ie&.#pp, add t'e ine


#include "StudentSet.h"

,ust before t'e ine :;ype te6t<

#include "StudentDoc.h"

11. E$i" "#e S"&$en".!

'ile.

8dd t'e ine #include "StudentSet.h" ,ust before t'e ine


#include "StudentDoc.h"

1..

B&il$ an$ "e%" "#e S"&$en" a

li!a"ion.

Re%&l", T#&% "#e S"&$en" a

li!a"ion i% exe!&"e$ %&!!e%%'&ll) in VC66.

E-..4, CREATING ACTIVE- CONTROL AIM, ;o &rite a 2. program for imp ementing t'e 8C;+259 #ontro . ALGORIT1M, 1. Create Oe& 8#tive6 Contro using Fi e-NOe&-N8#tive6 Contro . 2. P a#e t'e reBuired #omponents in t'e 8#tive6 Contro form. !. 5dit t'e #ode pertaining to t'e #omponents a#tion i)e CmdPe o = ?, CmdC ear =?, GserContro CHesiAe= ? in 8#tive6 #ontro . $. .ui d t'e a#tive6 fi e using Fi e-NMa)e Fi ename.7C9. %. 8dd t'e user #ontro in t'e standard e6e form using Pro,e#t -NComponents tab. (. ;o enab e t'e 'ands'a)ing bet&een t'e standard e6e form and a#tive6 form in#orporate #ode snippets in t'e events i)e *etCaption = ?, 3etCaption = ?, Cmdread#aptionC# i#)= ?, b read#aptionC# i#)= ?. -. Create ne& event in user #ontro as C i#)t'eevent = ?. /. Haise t'e #reated event in standard e6e form using Mouseup event. 0. .ui d and e6e#ute t'e app i#ation. Note !"ery ti#e an update is carried out in $cti"e% control& #a'e sure to reconstruct the acti"e% control (oc%
)ile* as situation warrants this. +oad the updated "ersion o) the control in standard e%e )or#.

PROGRAM, VVForm Coding 7ption 56p i#it Private "ub #mdread#aptionCC i#)=? b read#aption.#aption F #t My8#t61.#aption 5nd "ub Private "ub Command1CC i#)=? 5nd 5nd "ub :;ype te6t<

Private "ub #t My8#t61C# i#)red=? Msg.o6 DE7G C3+CK5D ;P5 H5DD 5nd "ub Private "ub b read#aptionCC i#)=? #t My8#t61.#aption F D453C7M5D #t My8#t61.#aption F #t My8#t61.#aption @ DP825 8 O+C5 D8ED 5nd "ub VV8#tive6 #ontro #oding 7ption 56p i#it Pub i# 5vent # i#)red=? Private "ub #md# earCC i#)=? ;e6t1.;e6t F DD 5nd "ub Private "ub #mdsayCC i#)=? ;e6t1.;e6t F DP5337D 5nd "ub Private "ub GserContro CMouseGp=.utton 8s +nteger, "'ift 8s +nteger, 9 8s "ing e, E 8s "ing e? Haise5vent # i#)red 5nd "ub Private "ub GserContro CHesiAe=? ;e6t1.;op F 1 ;e6t1.3eft F 1 ;e6t1.4idt' F "#a e4idt' ;e6t1.Peig't F %11 #mdsay.;op F ;e6t1.Peig't #mdsay.3eft F 1 #mdsay.4idt' F "#a e4idt' #mdsay.Peig't F %11 #md# ear.;op F ;e6t1.Peig't @ #mdsay.Peig't #md# ear.3eft F 1 #md# ear.4idt' F "#a e4idt' #md# ear.Peig't F %11 5nd "ub Pub i# Property *et #aption=? 8s "tring #aption F ;e6t1.;e6t 5nd Property Pub i# Property 3et #aption=.y2a Oe&#aption 8s "tring? ;e6t1.;e6t F Oe&#aption PropertyC'anged D#aptionD 5nd Property

:;ype te6t<

SAMPLE OUTPUT,

:;ype te6t<

RESULT, ;'us t'e 2. program for imp ementing t'e 8#tive6 #ontro 'as been e6e#uted su##essfu y.

E-..5 ,A!"i+e- Con"rol 0ialog Con"ainer Aim,


;o &rite a 2C@@ program to bui d an app i#ation t'at uses a Ca endar #ontro in a dia og using a#tive9.

Logi!al 0e%!ri "ion,


;'is pro,e#t is to generate t'e #a endar #ontro in a dia og using 8#tive9. 8n 8#tive9 #ontro is a soft&are modu e t'at p ugs into your C@@ program t'e same &ay a 4indo&s #ontro does. 8#tive9 Contro s met'ods are i)e fun#tions. 8 met'od 'as a symbo i# name, a set of parameters, and a return va ue. ;'e M"Ca .o#6 #ontro is a popu ar Mi#rosoft 8#tive9 Ca endar #ontro t'atYs probab y a ready insta ed and registered on your #omputer. MFC and C ass4iAard support 8#tive9 #ontro s bot' in dia ogs and as D#'i d &indo&s.D 7pen t'e dia og, enter a date in t'e t'ree edit #ontro s, and t'en # i#) t'e "e e#t Date button. C i#) t'e Oe6t 4ee) button. ;ry moving t'e se e#ted date dire#t y to a ne& mont', and observe t'e message bo6 t'at is triggered by t'e Oe&Mont' event. :;ype te6t<

4at#' for t'e fina date in anot'er message bo6 &'en you # i#) 7K. Press t'e F1 )ey for 'e p on t'e Ca endar #ontro .

S"e % 'or *&il$ing "#e !alen$ar a


1.

li!a"ion,

Veri') "#a" "#e Calen$ar !on"rol i% regi%"ere$. +f t'e #ontro does not appear in t'e 2isua C@@ *a eryYs Hegistered 8#tive9 Contro s page, #opy t'e fi es M"Ca .o#6, M"Ca .' p, and M"Ca .#nt to your system dire#tory and register t'e #ontro by running t'e H5*C7MP program.

2.

R&n A a. b. #. d.

8iMar$ "o ro$&!e G+!

2.G A!"i+e-.

"e e#t "ing e Do#ument in "tep 1 +n step!, ma)e sure t'e 8#tive9 Contro s option is se e#ted. Dese e#t Printing and Print Previe& in step $ of (. +n t'e 8pp4iAard "tep ! dia og, ma)e sure t'e 8#tive9 Contro s option is se e#ted. 2. In%"all "#e Calen$ar !on"rol in "#e Calen$ar roKe!". a. C'oose 8dd ;o Pro,e#t from 2isua C@@Ys Pro,e#t menu, and t'en #'oose Components 8nd Contro s. b. C'oose Hegistered 8#tive9 Contro s, and t'en #'oose Ca endar Contro /.1. #. C ass4iAard generates t&o # asses in t'e 8#tive9 dire#tory, as s'o&n 'ere.

4. a. :;ype te6t<

E$i" "#e Calen$ar !on"rol !la%% "o #an$le #el me%%age%. 8dd Calen$ar.! to t'e fo o&ing message map #ode>

&'()N_M'SS$('_M$*(CCalendar+ C,nd) -N_,M_H'.*)N/-() 'ND_M'SS$('_M$*()

b.

+n t'e same fi e, add t'e OnHelpInfo fun#tion>


&--. CCalendar00-nHelp)n%o(H'.*)N/-1 pHelp)n%o) 2 33 'd t t4e %ollo5 n! str n! %or your system 00, nHelp((etSa%eH5nd()+ 6c0775 nnt77system8977mscal#4lp6+H'.*_/)ND':+ ;); < return /$.S';

#.

+n Calen$ar.#, add t'e fun#tion prototype and de# are t'e message map>
protected0 a%x_ms! &--. -nHelp)n%o(H'.*)N/-1 pHelp)n%o); D'C.$:'_M'SS$('_M$*()

;'e OnHelpInfo fun#tion is #a ed if t'e user presses t'e F1 )ey &'en t'e Ca endar #ontro 'as t'e input fo#us. 4e 'ave to add t'e message map #ode by 'and be#ause C ass4iAard doesnYt modify generated 8#tive9 # asses. 5. U%e "#e $ialog e$i"or "o !rea"e a ne3 $ialog re%o&r!e. a. C'oose Hesour#e from 2isua C@@Ys +nsert menu, and t'en #'oose Dia og. b. ;'e dia og editor assigns t'e +D IDD_DIALOG1 to t'e ne& dia og. #. Oe6t #'ange t'e +D to IDD_ACTIVEXDIALOG, #'ange t'e dia og #aption to Acti eX Di!lo", and set t'e dia ogYs Conte6t Pe p property =on t'e More "ty es page?. d. 8##ept t'e defau t 7K and Can#e buttons &it' t'e +Ds IDO# and IDCA$CEL, and t'en add t'e ot'er #ontro s. e. ;'en add t'e ot'er #ontro s as s'o&n be o&>

:;ype te6t<

f. Ma)e t'e "e e#t Date button as t'e defau t button. g. Drag t'e Ca endar #ontro from t'e #ontro pa ette. '. ;'en set an appropriate tab order. i. 8ssign #ontro +Ds as s'o&n in t'e fo o&ing tab e. Con"rol Ca endar #ontro "e e#t Date button 5dit #ontro 5dit #ontro 5dit #ontro Oe6t 4ee) button I0 IDC_CALE$DAR1 IDC_SELECTDATE IDC_DA% IDC_&O$TH IDC_%EAR IDC_$EXT'EE#

7. U%e Cla%%8iMar$ "o !rea"e "#e C$cti"e,Dialog !la%%. a. +f you run C ass4iAard dire#t y from t'e dia og editor &indo&, it &i )no& t'at you &ant to #reate a CDi!lo"-derived # ass based on t'e IDD_ACTIVEXDIALOG temp ate. b. #. d. e. "imp y a##ept t'e defau t options, and name t'e # ass CActi eXDi!lo". C i#) on t'e C ass4iAard Message Maps tab, and t'en add t'e message 'and er fun#tions s'o&n in t'e tab e be o&. ;o add a message 'and er fun#tion, # i#) on an ob,e#t +D, # i#) on a message, and # i#) t'e 8dd Fun#tion button. +f t'e 8dd Member Fun#tion dia og bo6 appears, type t'e fun#tion name and # i#) t'e 7K button. :;ype te6t<

O*Ke!" I0 CActi eXDi!lo" IDC_CALE$DAR1 IDC_SELECTDATE IDC_$EXT'EE#

Me%%age 4MC+O+;D+837* Oe&Mont' =event? .OCC3+CK5D .OCC3+CK5D

Mem*er F&n!"ion OnInitDi!lo" =virtua fun#tion? On$ew&ont(C!lend!r1 OnSelectD!te On$e)t'ee*

IDO# .OCC3+CK5D OnO# =virtua fun#tion? 9. U%e Cla%%8iMar$ "o a$$ $a"a mem*er% "o "#e C$cti"e,Dialog !la%%. a. C i#) on t'e Member 2ariab es tab, and t'en add t'e data members as s'o&n in t'e i ustration be o&.

b. #.

Eou mig't t'in) t'at t'e C ass4iAard 8#tive9 5vents tab is for mapping 8#tive9 #ontro events in a #ontainer. ;'atYs not true> itYs for 8#tive9 #ontro deve opers &'o are defining events for a #ontro .

:. E$i" "#e C$cti"e,Dialog !la%%. a. 8dd t'e +_ !rV!lue and +_,!c*Color data members. b. 5dit t'e #ode for t'e five 'and er fun#tions OnInitDi!lo", n$ew&ont(C!lend!r1, OnSelectD!te, On$e)t'ee*, and OnO#. ;. A$$ "#e 'ollo3ing *ol$'a!e !o$e in "#e ACTIVE-0IALOG.1
,u+li#: C-le=ar ant m_>ar=alue;

:;ype te6t<

uns !ned lon! m_&ac?Color;

Oote> de# are t'ese 2 variab es at t'e end of t'e Dia og Data se#tion. 1<. E$i" "#e ACTIVE-0IALOG.CPP a. 8dd t'e fo o&ing *ol$'a!e #ode.
C-#tive.Dialog::C-#tive.Dialog(C/nd0 1,arent 203N45502) { m9sDay 3 :; m9sMont) 3 :; m9s;ear 3 :; 22}}-8.9D-T-96N6T } m_&ac?Color " ;x@;;;;;;/; : CDialog(C-#tive.Dialog::6DD7 1,arent) 22 {{-8.9D-T-96N6T (C-#tive.Dialog)

void C-#tive.Dialog::DoData%'#)ange(CData%'#)ange0 1D.) { CDialog::DoData%'#)ange(1D.); 22{{-8.9D-T-9M-,(C-#tive.Dialog) DD.9Control(1D.7 6DC9C-5%ND-<=7 m9#alendar); DD.9Te't(1D.7 6DC9D-;7 m9sDay); DD.9Te't(1D.7 6DC9M NTH7 m9sMont)); DD.9Te't(1D.7 6DC9;%-<7 m9s;ear); 22}}-8.9D-T-9M-, DDA_-CColor(pDA+ )DC_C$.'ND$:B+ D)S*)D_&$CCC-.-:+ m_&ac?Color); } > { CDialog:: n6nitDialog(); m_calendar#Set=alue(m_>ar=alue); 33 no DDA %or =$:)$NDs return T<4%; 22 return T<4% unless you set t)e ?o#us to a #ontrol 22 %.C%,T6 N: } void C-#tive.Dialog:: nNe@Mont)Calendar=() { $%xMessa!e&ox(6'='ND0 C$ct >eAD alo!00-nNe5Mont4CalendarB6); C. ,ro1erty ,ages s)ould return 8-5S% 5 C-#tive.Dialog:: n6nitDialog()

:;ype te6t<

} void C-#tive.Dialog:: nSele#tDate() { CData'xc4an!e dx(t4 s+ D:U'); DDA_Dext(Edx+ )DC_D$F+ m_sDay); DDA_Dext(Edx+ )DC_M-NDH+ m_sMont4); DDA_Dext(Edx+ )DC_F'$:+ m_sFear); m_calendar#SetDay(m_sDay); m_calendar#SetMont4(m_sMont4); m_calendar#SetFear(m_sFear); } void C-#tive.Dialog:: nNe't/ee!() { m_calendar#Next,ee?(); } void C-#tive.Dialog:: n A() { CDialog:: n A(); m_>ar=alue " m_calendar#(et=alue(); 33 no DDA %or =$:)$NDs }

11. ;'e OnSelectD!te fun#tion is #a ed &'en t'e user # i#)s t'e "e e#t Date button. ;'e fun#tion gets t'e day, mont', and year va ues from t'e t'ree edit #ontro s and transfers t'em to t'e #ontro Ys properties. C ass4iAard #anYt add DD9 #ode for t'e .a#)Co or property, so you must add it by 'and. +n addition, t'ereYs no DD9 #ode for VARIA$T types, so you must add #ode to t'e OnInitDi!lo" and OnO# fun#tions to set and retrieve t'e date &it' t'e #ontro Ys 2a ue property. 1.. Conne!" "#e $ialog "o "#e +ie3. a. Gse C ass4iAard to map t'e 4MC3.G;;7OD74O message, and t'en edit t'e 'and er fun#tion as fo o&s>
void -#tive.Vie@:: n5>uttonDo@n(46NT n8lags7 C,oint 1oint) { C$ct >eAD alo! dl!; dl!#m_&ac?Color " :(&(9GG+ 9GB+ 9H;); 33 l !4t yello5 C-leDateD me today " C-leDateD me00(etCurrentD me();

:;ype te6t<

dl!#m_>ar=alue " C-leDateD me(today#(etFear()+ today#(etMont4()+ today#(etDay()+ ;+ ;+ ;); % (dl!#DoModal() "" )D-C) 2 C-leDateD me date(dl!#m_>ar=alue); $%xMessa!e&ox(date#/ormat(6I& Id+ IF6)); < }

;'e #ode sets t'e ba#)ground #o or to ig't ye o& and t'e date to todayYs date, disp ays t'e moda dia og, and reports t'e date returned by t'e Ca endar #ontro . ;'en need to in# ude t'e fo o&ing in 8#tive92ie&.#pp. Oin!l&$e HA!"i+e-0ialog.#J 12. E$i" "#e +ir"&al OnDraw '&n!"ion in "#e 'ile A!"i+e-Vie3.! .

a. ;o prompt t'e user to press t'e eft mouse button, rep a#e t'e #ode in t'e vie& # ass OnDr!w fun#tion &it' t'is sing e ine>
pDCJKDext-ut(;+ ;+ 6*ress t4e le%t mouse button 4ere

RESULT, ;'us t'e program for 8#tive 9 dia og #ontainer 'as been su##essfu y
:;ype te6t<

e6e#uted and verified

PROGRESS CONTROL E-.NO, 0ATE,

AIM, ;o deve op t'e sing e t'readed program t'at #ontains t'e CPG intensive #omputation oop. PROCE0URE, "tep 1> Fi e-Nne&-NMFC 8pp&iAard=e6e? & # i#) "D+ app i#ation t'en finis' button. "tep 2> 7pen t'e resour#e vie& dia og fo der, rig't # i#) & #'oose insert dia og. "tep !> Design t'e dia og &it' start ,#an#e button & progress bar &it' t'e id +DC";8H;,+DCC8OC53 & +DCPH7*H5""1 respe#tive y. "tep $> C'oose vie&-N# ass&iAard, se e#t #reate a ne& dia og t'en give t'e name as K#omputeL & # i#) o) button. "tep %> "e e#t # ass name-N #ompute, ob,e#t +D is #ompute, messages-4MC;+M5H t'en # i#) add fun#tion. "tep (> se e#t ob,e#t id-N+DC";8H;,messages-N.OCC3+CK5D t'en # i#) add fun#tion and a so add fun#tion to +DCC8OC53 . fina y # i#) edit #ode. "tep -> se e#t fi e vie&-N'eader fi es-N#ompute.' fi e. De# are t'e variab e under # ass #ompute. "tep /> se e#t fi e vie&-Nsour#e fi es-Npro,e#tnamevie&.#pp. +n# ude 'eader
:;ype te6t<

fi e as K Sin# ude K#ompute.'L K.t'en type #oding under on dra& fun#tion. "tep 0> se e#t vie&-N# ass &iAard , se e#t ob,e#t +D -NCLpro,e#tnameLvie& messages-N4MC3.G;;7OD74O # i#) add fun#tion and edit #ode.

CO0ING, T) e in !om &"e.!

in %o&r!e 'ile%

void #ompute>>7nCan#e =? T if=mCn#ountFF1? CDia og>>7nCan#e =?R e se mCn#ountFnma6#ountR U void #ompute>>7n"tart=? T M"* messageR mCntimerF"et;imer=1,111,OG33?R 8""5H;=mCntimerZF1?R *etD g+tem=+DC";8H;?-N5nab e4indo&=F83"5?R vo ati e int tempR for=mCn#ountF1RmCn#ountMnma6#ountRmCn#ount@@? T for=tempF1RtempM11111Rtemp@@? TU if=>>Pee)Message=&message,OG33,1,1,PMCH5M725?? T >>;rans ateMessage=&message?R >>Dispat#'Message=&message?R U U CDia og>>7n7K=?R U void #ompute>>7n;imer=G+O; n+D5vent? T CProgressCtr IpbarF=CProgressCtr I?*etD g+tem=+DCCPH7*H5""1?R pbar-N"etPos=mCn#ount I111Vnma6#ount?R CDia og>>7n;imer=n+D5vent?R
:;ype te6t<

U 0e!lare "#e +aria*le in !om &"e.# in #ea$er 'ile% Un$er !la%% !om &"e , &*li! C0ialog int mCntimerR int mCn#ountR enumTnma6#ountF11111UR T) e in "#rea$%+ie3.! in %o&r!e 'ile% void C;'reads2ie&>>7nDra&=CDCI pDC? T C;'readsDo#I pDo# F *etDo#ument=?R 8""5H;C283+D=pDo#?R pDC-N;e6t7ut=1,1,DPress eft mouse buttonL?R U void C;'reads2ie&>>7n3.uttonDo&n=G+O; nF ags, CPoint point? T #ompute d gR d g.DoModa =?R C2ie&>>7n3.uttonDo&n=nF ags, point?R U
OUTPUT,

:;ype te6t<

:;ype te6t<

You might also like