Friend of Fiend: Co-creation at Coolhaven-island | Marseille & Mulder
Visualc tutorial
1. .snur margorp eht sa etacinummoc stcejbo ruof esehT
.derots si atad s’margorp
eht erehw si )ppc.coDemocleWxx dna h.coDemocleWxx( tcejbo tnemucod ehT •
.neercs eht no stcejbo rehto dna segassem yalpsid ot
su swolla elif ppc.weiVemocleW eht ni dohtem )(warDnO ehT .wodniw eht fo aera tneilc
eht ni atad syalpsid )ppc.weiVemocleWxx dna h.weiVemocleWxx( tcejbo weiv ehT •
.rab sutats dna rabloot ,rab unem
,rab eltit eht rof elbisnopser si )ppc.mrFniaM dna h.mrFniaM( tcejbo wodniw niam ehT •
.srehto ynam dna TNOFTES_MW
,wodniw eht seziser resu eht fi EZIS_MW ,stiuq resu eht fi TIUQ_MW edulcni
segassem esehT .wodniw niam eht ot metsys gnitarepo eht morf segassem swodniW
gnissap dna neercs eht no wodniw niam eht gnicalp ,margorp eht gnitrats :sksat eerht
sah tcejbo sihT .detrats margorp eht teg ot dohtem )(niaMniW eht gnillac yb tsrif snur
yllautca swodniW tahw si )ppc.emocleWxx dna h.emocleWxx( tcejbo noitacilppa ehT •
.margorp ++C lausiV a ni strap cisab ruof era
erehT .margorp ++C lausiV a etaerc ot sessalc noitadnuoF tfosorciM esu ot si pets tsrif ehT
tcejorp tsrif ruoy gnisinagrO
.spool roF detseN :11 ytivitcA
srebmun iccanobiF yalpsid ot pool tset-tsoP :01 ytivitcA
rotareneg rebmun modnaR :8 ytivitcA
repeeB pool tset-erP :7 ytivitcA
snoitaretI
tsoPlecraP :6 ytivitcA
noitceleS yawitluM
)noitceleS yraniB( retrevnoC tnemerusaeM :5 ytivitcA
noitceleS yraniB
ecneuqeS
orez yb noisivid diova dna rotaluclac a etaerC :4 ytivitcA
sexob golaiD :3 ytivitcA
snoitcnuf dna selbairaV ,sepytataD
regnahC ruoloC :2 ytivitcA
srab llorcs dna sreldnah tnevE
rotide uneM dna neercs emocleW :1 ytivitcA
:etagivan uoy pleh yam sgnidaeh gniwollof ehT
)15.p ,suballys DDS( .rennam lacidohtem
a ni noitulos erawtfos detnemucod dna detset ylluf a tnemelpmi ot nrael stnedutS
snoitulos erawtfos fo tnempoleved
dna ngised eht etatilicaf ot erawtfos etairporppa seilppa dna stceles tneduts A 3.5H
emoctuo suballyS
.)tset-tsop dna-erp :noitareti ,yawitlum dna yranib :noitceles
,ecneuqes( serutcurts lortnoc evif eht etartsnomed ot sesicrexe gnicudortni dna smret yek
gninifed ,ecafretni resu 23 swodniW a tnemelpmi ot sessalc CFM fo esu eht dna tnemnorivne
gnimmargorp eht gnicudortni ,6 ++C lausiV ot ediug s’rennigeb a sniatnoc lairotut sihT
lairotuT gnimmargorP 6 ++C lausiV
2. .tnof dlob ni senil owt eht dda dna edoc eht fo noitces siht dnif ,weiv
ecapskroW eht ni gnikcilc elbuod yb h.coDemocleWxx nepO .elif redaeh s’tnemucod
eht ni gnirts_yojne dna gnirts_emoclew selbairav gnirts owt gniralced yb tratS •
.evoba debircsed stcejbo ruof eht
fo hcae ot gnignoleb selif eht rof kool ot wodniw ecapskroW eht ni bat weiVeliF eht esU •
.spets rehto eht lla rof stluafed eht tpecca nehT .tnemucod elgniS tceles ,1 petS nI •
.draziWppA CFM eht trats ot KO kcilc dna noitacol a
esoohc ,xob eman tcejorP eht ni emocleWslaitini ruoy eman eht margorp wen eht eviG •
.xob golaid weN eht ni
bat stcejorp eht rednu yrtne )exe( draziWppA CFM eht tceles ,unem eliF eht ni weN kcilC •
++C lausiV nepO •
meti unem a gnidda dna neercs emoclew a gnitaerC :1 ytivitcA
3. // xxWelcomeDoc.h : interface of the xxWelcomeDoc class
//
/////////////////////////////////////////////////////////////////////////////
#if
!defined(AFX_xxWELCOMEDOC_H__9442116A_C7A7_11D3_BBC0_0000E883F891__INCLUDED_)
#define AFX_xxWELCOMEDOC_H__9442116A_C7A7_11D3_BBC0_0000E883F891__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class xxWelcomeDoc : public CDocument
{
protected: // create from serialization only
xxWelcomeDoc();
DECLARE_DYNCREATE(xxWelcomeDoc)
CString welcome_string;
CString enjoy_string;
• s’ssalc stnemucod eht ni stcejbo gnirts_yojne dna gnirts_emoclew eht ezilaitini woN
tegrof t’noD .edoc fo senil dlob eht gnidda yb ppc.coDemocleWxx elif eht ni rotcurtsnoc
sa enil hcae fo dne eht ta ; eht gnicalp dna yltcaxe gniypoc tuoba yssuf yrev eb ot
.nwohs
// xxWelcomeDoc construction/destruction
xxWelcomeDoc:: xxWelcomeDoc ()
{
welcome_string = "Welcome to Visual C++";
enjoy_string = "Enjoy!";
// TODO: add one-time construction code here
}
• senil eht ddA .elif ppc.weiVemocleWxx eht nepo ,neercs eht no segassem eht yalpsid oT
eht htiw snoisnemid wodniw eht gnitteg( txet ruoy ertnec lliw edoc sihT .nwohs sa
eht flah ruoloc ,)dohtem )(tnemucoDteG eht htiw txet eht dna dohtem )(tceRwodniWteG
.gnihctah ssorc eulb-yneerg htiw dellif espille na dda dna eulb neercs
// xxWelcomeView drawing
void xxWelcomeView::OnDraw(CDC* pDC)
{
xxWelcomeDoc* pDoc = GetDocument(); //Declare a pointer variable
ASSERT_VALID(pDoc); //An error handler macro
CRect rect;
GetWindowRect(&rect); //Find the Windows dimensions
int x = rect.Width()/2; //and create some variables to
int xx = rect.Width()/2; //position text
int xxx = rect.Width()/2;
int y = rect.Height();
int yy = rect.Height()/2;
int yyy = rect.Height()- 20;
// Construct brushes to do the
CBrush myBrush; cross hatching and background
CBrush backBrush; colour
// Then initialize and use them.
if(myBrush.CreateHatchBrush(HS_DIAGCROSS, RGB(0, 200, 240)))
{
CBrush* pOldBrush = pDC->SelectObject( &myBrush );
4. }
// TODO: add one-time construction code here
StringData = "";
enjoy_string = "Enjoy!";
welcome_string = "Welcome to Visual C++";
{
xxWelcomeDoc:: xxWelcomeDoc ()
// xxWelcomeDoc construction/destruction
.rotcurtsnoc
s’tnemucod eht ni tcejbo gnirts eht ezilaitini dna ppc.coDemocleWxx nepo nehT •
CString StringData;
virtual ~CShwelcomeDoc();
public:
.tcejbo gnirts eht eralced ot tnof dlob
ni edoc eht dda dna h.coDemocleWxx elif eht nepO .gnirts eht erots ot ataDgnirtS dellac
elbairav a esilaitini dna eralced ot deen ew siht od oT .neercs eht fo mottob eht no
deretnec ”sunem ot emocleW“ yalpsid lliw ew ,meti unem wen ruo skcilc resu eht nehW •
.ti tpecca ot KO kcilC .)(emocleWtnirPeliFnO fo reldnah tneve eht
rof eman eht gnitseggus xob egassem a pu sgnirb sihT .xob segasseM eht ni dnammoC
kcilc elbuod neht ,tsil sdI stcejbO eht ni EMOCLEWTNIRP_ELIF_DI tceles dna dniF
.xob eman ssalC eht ni detceles ssalc eht si weiVemocleWxx erus ekaM .reldnah tneve
na ot meti unem wen eht tcennoc ot )unem weiV eht rednu dnuof( draziWssalC eht esU •
ID_FILE_PRINTWELCOME. DI eht meti unem wen eht sevig sihT .xob eht esolc dna
xob noitpac eht ni
Print Welcome noitpac eht ecalp ,xob seitreporP metI uneM eht nepo
ot kcilc elbuoD .smeti unem puteS tnirP dna weiverP tnirP neewteb ot pu ti gard dna
)yrassecen fi xob a dda ot yek tresnI esu( mottob eht ta xob eht barg dna nepo ot unem
eliF eht no kcilC .EMARFNIAM_RDI kcilc elbuod neht ,unem ediseb + eht kcilc ,wodniw
ecapskroW eht ni bat secruoser eht kcilC .rotide unem eht esu ,meti unem a dda oT •
.uneM dliuB eht
morf etucexe RO noci kram noitamalcxe der htiw margorp uoy nuR .niaga dliub dna .cte
,gnipyt ssim ,snolocimes ,stekcarb gnissim rof ylluferac kcehc dna edoc fo enil eht ot uoy
ekat ot kcilc elbuod ,srorre yna evah uoy fi .yek noitcnuf 7F eht htiw margorp ruoy dliuB •
}
pDC->TextOut(xx, yy, pDoc->enjoy_string);
xx += (size2.cx/2 + 50);
CSize size2 = pDC->GetTextExtent(pDoc->enjoy_string);
//Position and display enjoy_string
// TODO: add draw code for native data here
pDC->TextOut(x, 0, pDoc->welcome_string);
x -= size.cx/2;
CSize size = pDC->GetTextExtent(pDoc->welcome_string);
//Centre and display welcome_string
}
pDC-> SelectObject(pOlderBrush);
pDC->Rectangle (x*2,y,x,0);
CBrush* pOlderBrush = pDC->SelectObject (&backBrush);
{
if(backBrush.CreateSolidBrush(RGB(0,0,250)))
}
pDC->SelectObject( pOldBrush );
pDC->Ellipse(CRect(50, 100, 250, 250));
5. .ecnatirehni yb
ssalc taht morf devired ro ssalc taht fo stcejbo ot ssecca evig ot desu si drowyek detcetorp
ehT .margorp eht fo strap rehto lla ot elbaliava si rebmem taht taht snaem drowyek
cilbup ehT .etavirp sa srebmem atad lla eralced ot lausu si tI .noitcnuf ro rebmem atad taht
ot ssecca evah ssalc taht fo stcejbo ylno taht snaem drowyek etavirp ehT .sessalc nihtiw
snoitcnuf dna srebmem atad fo epocs eht tes ot desu sdrowyek era sreifidom sseccA
.dedda serutaef artxe evah dna ssalc esab sti fo seitreporp
eht lla tirehni nac ssalc devired a ,ecnatirehni gnisU .ecnatirehni stroppus osla ++C lausiV
.sepyt esoht fo stcejbo gnitaerc era ew ,snottub dnammoc ro slebal
etaerc ew nehW .krow fo laed taerg a sevas hcihw ,yrarbil CFM eht ,sessalc denifederp
fo yrarbil a htiw etelpmoc semoc ++C lausiV .selif )ppc.( edoc ecruos eht ni detaerc era
)epyt s’ssalc taht fo selbairav sa fo thguoht eb nac hcihw( ssalc taht fo stcejbo dna denifed
era sessalc ,gnimmargorp ++C nI era atad eht gnildnah rof sdohtem dna atad ,noitinifed
ssalc eht nI .tcejbo na etaerc ot desu si taht )etalpmet ro( noitpircsed a si ssalc A
.)(eniLward ro
)(warDnO ekil ,atad taht eldnah ot )sdohtem ro( snoitcnuf eht dna neercs eht no deyalpsid
eb ot atad eht htob edulcni dluoc tcejbo neercs sihT . screen dellac tcejbo na ni rehtegot
tup eb thgim margorp a fo strap gnildnah neercs eht lla ,elpmaxe roF .noitaluspacne
dellac si rehtegot gnipuorg sihT .ksat etercsid a mrofrep ot rehtegot pu depparw selbairav
dna snoitcnuf sniatnoc dna neercs eht no sraeppa taht gnihtyna — gniht a si tcejbo nA
.++C ekil segaugnal detneiro-tcejbo ni stpecnoc latnemadnuf owt era sessalc dna stcejbO
srab llorcs dna sreldnah tnevE
your code. What happens when you click on the Print Welcome menu item?
Build your code with the F7 function key. When it is free of errors, run •
}
pDC->TextOut(xxx, yyy, pDoc->StringData);
yyy -= 20 ;
xxx -= menuSize.cx/2;
CSize menuSize = pDC->GetTextExtent(pDoc->StringData);
.
. // This represents existing code
{
void xxWelcomeView::OnDraw(CDC* pDC)
the text in StringData
Finally we add the code to the end of OnDraw() in xxWelcomeView.cpp to display •
}
Invalidate();
//Invalidate calls the OnDraw()method to display the new string
pDoc->StringData = "Welcome to menus!";
ASSERT_VALID(pDoc);
xxWelcomeDoc* pDoc = GetDocument();
{
void xxWelcomeView::OnFilePrintwelcome()
.ppc.weiVemocleWxx ni edoc gniwollof eht dda ew ,emocleW
tnirP skcilc resu eht nehw tcejbo ataDgnirtS eht ni sunem ot emocleW“ gnirts eht dda oT •
6. .emit hcae devom si rab llorcs hcihw
dnif ot desu eb lliw sihT .epyt elbairaV eht rof raBllorcsC dna yrogetaC eht rof lortnoC
esoohc ,ylevitcepser 3edils_m dna 2edils_m ,1edils_m meht emaN .elbairaV ddA gnisu
,rab llorcs hcae ot eman a evig ,draziW ssalC eht fo bat selbairaV rebmeM eht ni llitS •
.)3txet_m htiw( 3TIDE_CDI dna )2txet_m
gnisu( 2TIDE_CDI rof pets siht taepeR .epyt elbairav ruoy rof gnirtSC esoohc dna
yrogetac )eulav( tluafed eht tpecca ,1txet_m ti emaN .elbairaV ddA neht ,xob sdI lortnoC
eht ni 1TIDE_CDI no kcilC .draziW ssalC ni bat selbairaV rebmeM eht ot egnahc woN •
.raB llorcS ralucitrap a ot etaler ton seod siht taht etoN .snoitcnuf
rebmem eht ot llorcSHnO dda ot kcilc elbuoD .LLORCSH_MW dnif uoy litnu segasseM
eht nwod llorcs nehT .detceles eman ssalc eht si glDregnahCruoloCC taht dna detceles
si bat spaM egasseM eht erus ekaM .draziW ssalC eht nepo ot unem weiV eht esU •
.xob golaid eht no lebal hcae ot ylppa lliw sihT .llew skrow 21 kcalB lairA .tnof a tceles
ot siht esu dna seitreporP sti pu gnirb ot xob golaid eht fo dnuorgkcab eht kcilc thgiR
. ylevitcepser Blue dna Red, Green eerht rehto eht dna Colour Changer noitpac
eht lebal pot eht eviG .redrob a meht evig dna yllacitrev ertnec ,ertnec:txet ngila
,)bat selyts eht rednu( hcae rof dna xob seitreporp eht pu gnirb ot lebal hcae kcilc thgiR •
.siht htiw pleh lliw unem tuoyaL ehT .nwohs sa srab llorcs eht dna
lebal pot eht neewteb ecaps emos evaeL .margaid eht ni nwohs sa yltaen meht egnarrA
.pot eht ssorca lebal a dna meht ediseb sexob tide eerht dda ,txeN .ylneve meht
egnarra dna meht ngila ,ezis emas eht meht ekam ot unem tuoyal eht esu dna lla tceleS
.xobloot eht morf srab llorcs latnoziroh eerht dda nehT .eteled dna .. ODOT eht no kcilC •
.spets rehto eht ni stluafed eht tpecca dna desab golaid tceles ,1 petS draziWppA nI •
.regnahCruoloC
ti llac dna )exe( draziWppA CFM eht gnisu ecapskrow wen a ni tcejorp wen a nepO •
regnahC ruoloC :2 ytivitcA
.ksat eht etelpmoc taht
sdohtem ot atad refsnart sreldnah tnevE .neercs eht no neppah taht sgniht era stnevE
7. • dna gnikcilc thgir yb ruoloc eht ees ot kcilC ot noitpaC sti egnahc dna nottub a ddA
,bat spaM egasseM eht tceles ,niaga draziW ssalC eht nepo nehT .seitreporP gninepo
elbuod dna 1NOTTUB_CDI tceles ,detceles ssalc eht si glDregnahCruoloCC erus ekam
.noitcnuf rebmem 1nottuBnO eht dda ot DEKCILC_NB egassem eht kcilc
• ssalc eht dniF .elif edoc ecruos ppc.glDregnahCruoloCC eht ot edoc emos dda woN
.dlob ni edoc eht dda dna noitasilaitini
BOOL CColourChangerDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_slide1.SetScrollRange(1,255, true); //Set scroll bar range and
m_text1 = "1"; //intitialise edit boxes to 1
m_slide2.SetScrollRange(1,255, true);
m_text2 = "1";
m_slide3.SetScrollRange(1,255, true); //This updates data from the
m_text3 = "1"; //variable to the edit box.
UpdateData(false); //(True) updates data from
//the textbox to the variable.
n_red = 1;
n_green = 1; //Declare and initialise three
n_blue = 1; //integer variables.
// Add "About..." menu item to system
menu.
• eht daer ot dohtem llorcSHnO::glDregnahCruoloCC diov eht ot edoc gniwollof eht ddA
dna neerg_n ,der_n ,selbairav eerht eht otni dna sexob tide eht otni eulav rabllorcs
.eulb_n
void CColourChangerDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar*
pScrollBar)
{
if(nSBCode == SB_THUMBPOSITION)
{
if (pScrollBar == &m_slide1){
m_text1.Format("%ld", nPos);
UpdateData(false);
n_red = nPos; }
if (pScrollBar == &m_slide2){
m_text2.Format("%ld", nPos);
UpdateData(false);
n_green = nPos;}
if (pScrollBar == &m_slide3){
m_text3.Format("%ld", nPos);
UpdateData(false);
n_blue = nPos;}
}
else
{
CDialog::OnHScroll(nSBCode, nPos,
pScrollBar);
}
}
• nI .dohtem )(1nottuBnO::glDregnahCruoloCC diov eht ot edoc dda ot si pets tsal ehT
eralced dna ot ward ot )CDp( txetnoc ecived wen a tcurtsed dna tcurtsnoc ew ,edoc siht
dna orcam BGR eht ni denifed sruoloc eht tniap ot ssalc hsurBC eht fo tcejbo wen a
eht dda niagA .reilrae deralced selbairav eulb_n dna neerg_n ,der_n eht yb denimreted
.dlob ni edoc
8. .stnemugra fo selpmaxe htob era cubed dna myValue
.htiw krow ot atad sah noitcnuf eht os noitcnuf a ot ssap uoy eulav a si tnemugra nA
.)ssalc eht fo sdohtem dellac( snoitcnuf detaler dna atad enibmoc sessalC
//squared = 64 unsigned long squared = square(cubed)
//cubed = 8 unsigned long cubed = cube(myValue)
unsigned long myValue = 2;
// at the beginning of this code.
//NB This code depends on using the #include <CMath> header file
.g.e ,sksat lacitamehtam cisab mrofrep emoS .tluser elgnis
a snruter dna stnemugra erom ro eno ,orez stpecca taht edoc fo tnemges a si noitcnuf A
sepytatad denifederp no desab sepytatad gninifed roF mune
sretcarahc ciremunahpla fo sgnirts gnildnah
rof ssalc ++C denifederp A .epytatad elpmis a yllaer toN gnirtSC
)stigid 91( 2394 -/+ E2.1 ta
elbuod gnol a evah osla nac uoY(
)stigid 51( 803 -/+ E7.1 ot srebmun laeR elbuod
)stigid 7( 83 -/+ E4.3 ot srebmun laeR taolf
746,384,741,2 ot 846,384,741,2– morf seulav regetnI tni gnol
592,769,492,4 ot 0 morf seulav regetnI tni gnol dengisnu
767,23 ot 867,23– morf sregetnI tni trohs
.)tnedneped )tni RO(
metsys si tni redlo eht tub( 535,56 – 0 morf sregetnI trohs dengisnu
552-0 morf slamiced tuohtiw seulav ciremun evitisoP rahc dengisnu
eslaF ro eurT .g.e .ylno seulav owt fo enO loob
egnaR dna noitpircseD epytataD
.++C ni elbaliava sepytatad elpmis eht fo emos stsil elbat gniwollof ehT
.epytatad deralced eht yb denimreted ezis a fo snoitacol yromem deman era selbairaV
snoitcnuf dna sepytatad ,selbairaV
.edoc ruoy etucexe dna )7F( dliub woN •
}
ereh edoc reldnah noitacifiton lortnoc ruoy ddA :ODOT //
delete pDC;
}
;)hsurBredlOp(tcejbOtceleS >-CDp
pDC-> Ellipse(50,70, 140,130);
CBrush* pOlderBrush = pDC->SelectObject (&backBrush);
{
if(backBrush.CreateSolidBrush(RGB(n_red,n_green,n_blue)))
CBrush backBrush;
CClientDC* pDC = new CClientDC(this);
{
void CColourChangerDlg::OnButton1()
9. CDialog::DoDataExchange(pDX);
{
void Dlg::DoDataExchange(CDataExchange* pDX)
.ppc.gld ot edoc dlob eht ddA .ssalc )(egnahcxEataDoD
eht f0 dohtem )(txet_XDD eht gnisu lortnoc TIDE_CDI eht ot txet_m tcennoC •
.gnirtSC
epyt sa yrogetac eulav eht fo txet_m elbairav eht etaerC .nottub elbairaV ddA eht kcilc
dna 1TIDE_CDI tceles ,draziW ssalC eht fo bat selbairaV rebmeM eht ot egnahc woN •
.)(1nottuBnO noitcnuf rebmem wen eht setaerc sihT .xob
segasseM eht ni yrtne DEKCILC_NB eht kcilc elbuod dna 1NOTTUB_CDI tceles ,nottub
eht ot reldnah tneve na tcennoc oT .KO kcilC .glD ti eman dna ssalc wen a etaerc
esoohC .ssalc xob golaid wen a etaerc ot unem weiV eht morf draziW ssalC esoohC •
.)”!em ot klaT“ noitpac eht htiw( nottub a dna htaenrednu xob tide na ddA •
”.esaelp eman
ruoy ni epyT“ ot noitpac eht egnahC .seitreporp sti nepo dna kcilc thgir ,lebal a ddA •
.rotide xob golaiD eht snepo
sihT .nottub wen eht kcilc dna yrtne golaiD eht tceleS .xob ecruoseR tresnI eht snepo
sihT .unem tresnI eht morf meti ecruoseR eht tceles ,xob eugolaid tupni na etaerc oT •
.spets rehto eht lla rof stluafed eht tpecca nehT .tnemucod
elgniS tceles ,1 petS nI .draziWppA CFM eht trats ot KO kcilc dna noitacol a esoohc
,xob eman tcejorP eht ni noitasrevnoCretupmoC eman eht margorp wen eht eviG •
.xob golaid weN eht ni bat stcejorp eht rednu yrtne
)exe( draziWppA CFM eht tceles ,unem eliF eht ni weN gnitceles yb margorp wen a tratS •
.neercs eht fo aera tneilc niam eht no egassem desilanosrep a yalpsid
ot atad taht esu dna atad tupni ot resu a wolla ot xob golaid a esu lliw ew margorp siht nI
sexob golaiD :3 ytivitcA
.nolocimes a htiw dedne ton
si flesti noitcnuf eht tub ,snolocimes ni dne tsum secarb eht nihtiw stnemetats llA .noitcnuf
eht fo ydob eht dnuorrus tsum secarb dna ,sretemarap eht lla rof seman edivorp tsum
tI .tsil retemarap dna epyt nruter ni epytotorp sti htiw eerga tsum noitinifed noitcnuf A
}
return l*w;
{
int CalculateArea(int l, int w)
,elpmaxe roF
}
;stnemetats
{
)…]emaNretemarap epyt[( eman_noitcnuf epyt_nruter
:xatnys siht gnisu skrow noitcnuf eht woh relipmoc eht sllet noitinifed noitcnuf ehT
.nolocimes a htiw sdne
syawla epytotorp A .denruter eb ot si eulav on fi epyt nruter eht ekat yam noitcnuf
void
A .ytpme fi neve sesehtnerap eht niatnoc tsum tub sretemarap evah ot deriuqer ton era
snoitcnuF .tsil retemarap dna eman ,epyt nruter eht relipmoc eht sllet epytotorp noitcnuf A
int CalculateArea(int length, int width); ,elpmaxe roF
;)… ]]emaNretemarap[epyt[( eman_noitcnuf epyt_nruter
:xatnys gniwollof eht gnisu epytotorp noitcnuf a ni deralced si noitcnuf A
10. //to close the dialog box and return the value IDOK.
UpdateData(true);
// to make sure m_text is holding the text from the edit box
// TODO: Add extra validation here
{
void Dlg::OnOK()
.edoc dda woN .]DEKCILC_NB kcilcelbuod dna ,KODI dniF[
.ppc.glD ot dohtem )(KOno eht dda ot draziWssalC eht esU .nottub KO eht htiw desolc
si xob golaid eht retfa neercs tneilc eht ot txet_m ni egassem eht dda ot si pets tsal ehT •
}
// TODO: add construction code here
int display = dlg.DoModal();
Dlg dlg;
CView::OnInitialUpdate();
{
void CComputerConversationView::OnInitialUpdate()
]xob segassem
eht ni etadpUlaitinInO kcilcelbuod dna detceles ssalc eht si weiVnoitasrevnoCretupmocC
erus ekaM[ .dohtem etadpUlaitinInO eht dda ot draziWssalC eht esU
].desolc si ti retfa niaga xob golaid eht wohs ot resu eht elbane ot dohtem siht ot edoc
fo senil emas eseht dda nac uoy )(golaidwohSeliFnO dohtem s’ssalc weiv eht ot eciohc
unem taht tcennoc dna unem elif s’margorP eht ot meti golaiD wohS a dda uoy fI :BN[
.eulav regetni na snruter hcihw ,dohtem )(ladoMoD eht htiw neercs eht no ti gniyalpsid
dna ssalc taht fo tcejbo wen a gnitaerc yb ssalc glD ruo fo esu ekam nac ew woN •
#include "Dlg.h"
#include "ComputerConversationView.h"
#include "ComputerConversationDoc.h"
#include "ComputerConversation.h"
#include "stdafx.h"
//
// ComputerConversationView class
// ComputerConversationView.cpp : implementation of the
.ppc.weiVnoitasrevnoCretupmoC
ni elif redaeh h.glD eht gnidulcni yb ssalc weiv eht ni ssalc glD ruo
rof troppus eht edulcni ot evah ew siht od oT .xob golaid eht gniyalpsid si pets txen ehT •
}
// TODO: Add your control notification handler code here
AfxMessageBox(m_text);
UpdateData(false);
m_text = "Hello there, " + m_text + "!";
UpdateData(true);
{
void Dlg::OnButton1()
.)eurt(ataDetadpU htiw neercs niam eht ot kcab yalpsid dna
xob egassem a yalpsid ,noitanetacnoc gnirts htiw ”,ereht olleH“ ddA .elbairav eht ot xob
tide eht morf sdaer hcihw )eslaf(ataDetadpU gnisu xob tide eht morf eman resu eht teG •
}
//}}AFX_DATA_MAP
DDX_Text(pDX, IDC_EDIT1, m_text);
//{{AFX_DATA_MAP(Dlg)
11. .spets rehto eht ni stluafed eht tpecca dna desab golaid tceles ,1 petS draziWppA nI •
.rotaluclaC
ti llac dna )exe( draziWppA CFM eht gnisu ecapskrow wen a ni tcejorp wen a nepO •
.resu eht yb nevig srebmun
owt edivid dna ylpitlum ,tcartbus ,dda nac taht rotaluclac a etaerc ot xob golaid a esU
orez yb noisivid diova dna rotaluclac a etaerC :4 ytivitcA
.yletelpmoc derongi
si edoc fo enil taht ,kramer eht fo tnorf ni decalp si // fI .ecnanetniam edoc rof noitamrofni
dda ot ro edoc fo noitces a fo esoprup eht nialpxe ot edoc ni dedda era skrameR
.ti nur dna )ylluferac srorre yna gubed( ti dliuB .etelpmoc si margorp ehT •
}
pDC->TextOut(0,0,pDoc->StringData);
// TODO: add draw code for native data here
ASSERT_VALID(pDoc);
CComputerConversationDoc* pDoc = GetDocument();
{
void CComputerConversationView::OnDraw(CDC* pDC)
.dohtem
)(warDnO s’weiv eht ni xob golaid eht morf txet eht ward ,margorp eht etelpmoc oT •
// Operations
CString StringData;
public:
// Attributes
DECLARE_DYNCREATE(CComputerConversationDoc)
CComputerConversationDoc();
protected: // create from serialization only
{
class CComputerConversationDoc : public CDocument
.h.coDnoitasrevnoCretupmoCC ot ataDgnirtS deman tcejbo gnirtSC a ddA •
}
}
Invalidate();
pDoc->StringData = dlg.m_text;
ASSERT_VALID(pDoc);
CComputerConversationDoc* pDoc = GetDocument();
if(display ==IDOK){
// TODO: add construction code here
int display = dlg.DoModal();
Dlg dlg;
CView::OnInitialUpdate();
{
void CComputerConversationView::OnInitialUpdate()
.yalpsid eht etadpu ot ppc.weiVnoitasrevnoCretupmoCC ot edoc ddA •
}
CDialog::OnOK();
12. .etad eht dna eman ruoy sedulcni hcihw edoc ruoy fo pot
eht ta )enil eht fo gninnigeb eht ta // tup( kramer a ddA .margorp ruoy nur dna dliuB •
}
// TODO: Add your control notification handler code here
}
UpdateData(false);
answer = number1 / number2;
else {
}
int display = error.DoModal();
dlg error;
if (number2 == 0){
UpdateData(true);
{
void CCalculatorDlg::OnDivide()
.dohtem ediviDnO eht ni orez yb noisivid tneverp ot } …];stnemetats[
{ esle }… ];stnemetats[ { )noitidnoc( fi erutcurts lortnoc noitceles yranib eht esU •
#include "dlg.h"
#include "CalculatorDlg.h"
#include "Calculator.h"
#include "stdafx.h"
//
// CalculatorDlg.cpp : implementation file
.xob golaid wen eht ssecca ot edoc dda dna niaga ppc.glDrotaluclaC nepO •
.gld dellac ssalc wen a etaerc ot stluafed eht tpecca
dna xob golaid wen eht kcilc elbuoD ].seitreporp sti gnitceles dna dnuorgkcab xob golaid
eht gnikcilc thgir yb ezis tnof ssecca nac uoy ,rebmemeR[ .”rebmun rehtona retne
esaelP !orez yb edivid tonnac uoY“ daer ot noitpac eht egnahc ,seitreporp eht ssecca
ot kcilc thgir ,pot eht ssorca lebal citats a ecalP .golaid wen a dda ..ecruoseR ,unem
tresnI eht morF .orez yb noisivid tpmetta ton seod margorp eht taht erusne ot woN •
}
/ /TODO: Add your control notification handler code here
UpdateData(false);
answer = number1 + number2;
UpdateData(true);
{
void CCalculatorDlg::OnAdd()
.yletairporppa enil dnoces eht ni rotarepo
eht gnignahc ,ediviDnO dna ylpitluMnO ,tcartbuSnO ot edoc emas eht dda ,etsap
dna tuc gnisU .dohtem ddAnO eht ot edoc gniwollof eht dda dna ppc.glDrotaluclaC nepO •
.ediviDnO dna ylpitluMnO
,tcartbuSnO ,ddAnO ot seman noitcnuf rebmem eht egnahc tub tneve DEKCILC_NB rieht
kcilc elbuod ,niaga draziW ssalC gnisU .ediviD dna ylpitluM ,tcartbuS ,ddA ot snoitpac
rieht egnahc dna seitreporP ssecca ot hcae kcilc thgir dna enil a ni snottub llams 4 ddA •
. answer
eulav taolf a ot tcennoc dna mottob eht ta xob tide rehtona ddA . ro
number2 number1
eulav ,taolf a ot hcae tcennoc ot unem weiV eht morf draziW ssalC eht esU .unem tuoyaL
ni sloot gnisu pu meht enil dna sexob tide owt ddA .eteled dna .. ODOT eht no kcilC •
13. .Close ot nottub lecnac eht fo noitpac eht dna Convert ot nottub
KO eht fo noitpac eht egnahC .) answerdeman taolf a ot detcennoc( xob tide rehtona
dna ”smc ot sehcni“ dna ”sehcni ot smc“ dellebal snottub oidar owt ddA .tupni resu eht
niatbo ot )draziWssalC eht yb measurement deman taolf a ot detcennoc( xob tide na esU •
.e.i
.emit a ta detceles eb nac eno ylno ,evisulcxe yllautum era snottub noitpO .detceles
si nottub noitpo hcihw no desab esu ot alumrof hcihw enimreted ot stnemetats fI esU •
.sehcni ot sertemitnec ro sertemitnec ot sehcni
si noisrevnoc eht rehtehw etacidni ot resu eht rof )xobloot eht morf( snottub noitpo esU •
.)sertemitnec 45.2 = hcni 1 noisrevnoc eht gnisu( sehcni ot sertemitnec RO sertemitnec
ot sehcni trevnoc ot retrevnoC dellac )desab golaid niaga( margorp wen a etaerC •
.smc 45.2 si sertemitnec ni tnemerusaem ehT
!ti trevnoC
tnemerusaem eht retnE
1
sertemitneC ro sehcnI ni tnemerusaem ruoy sI
)noitceleS yraniB( retrevnoC tnemerusaeM :5 ytivitcA
.orez yb gnidivid resu a tneverp ot rotaluclac
ruoy ni noitceles yranib desu evah uoY .)seciohc elpitlum( yawitluM ro )yaw owt( yraniB
eb nac stcurtsnoc noitceleS .edam eb ot seciohc rof swolla dna tneve yna rof syawhtap
elpitlum swolla noitceleS .noitceles — tcurtsnoc mhtirogla dnoces eht desu osla evah eW
smhtirogla noitceleS yraniB
}
// Output answer UpdateData(false);
// Calculate answer answer = number1 + number2;
// Input user numbers UpdateData(true);
{
void CCalculatorDlg::OnAdd()
.g.e ,spets ssecorp
dna tuptuo ,tupni fo tsisnoc dluow mhtirogla eht ,noitcnuf rebmem hcae rof ,oS .tneve
hcae rof yawhtap elbissop eno ylno htiw rehtona dewollof edoc fo enil hcaE .stcurtsnoc
mhtirogla ecneuqes morf detcurtsnoc ylniam erew 4 — 1 seitivitcA ni smargorp ehT
smhtirogla ecneuqeS
14. }
tnemetats :tluafed
.
.
.
;kaerb
;tnemetatS :noisserpxEtnatsnoC esac
{
tnemetatS )noisserpxEmunErOlargetni( hctiws
.stnemetats hctiwS hguorht noitceles elpitlum rof
xatnys eht si ereH .stnemetats hctiwS esu ot retteb semitemos si tI .edoc daer-ot-drah ot
dael nac dna detacilpmoc si siht tub stnemetats fI detsen esu nac uoy ,sevitanretla owt naht
erom sevlovni noitceles eht fI .noitceles yranib fo elpmaxe na ta dekool ew ,5 ytivitcA nI
noitceles yawitluM
.456789000000.0 ,srebmun evitagen ,orez ,srebmun llams yrev ,srebmun egral
yrev gnidulcni atad tset emos htiw tuo ti yrT .stluser eht yfirev ot rotaluclac ruoy esU •
.yltcerroc gnikrow si ti taht erusne ot noitacilppa eht nur dna dliuB •
}
//CDialog::OnOK();
}
UpdateData(false);
unit = "inches";
answer = float(measurement / 2.54);
else {
}
UpdateData(false);
unit = "cms";
answer = float(measurement * 2.54);
if (flag == false) {
UpdateData(true);
{
void CConverterDlg::OnOK()
}
flag = false;
{
void CConverterDlg::OnRadio2()
}
flag = true;
{
void CConverterDlg::OnRadio1()
.tnof dlob ni edoc gniwollof eht dda dna ppc.glDretrevnoC nepO •
bool flag;
// standard constructor CConverterDlg(CWnd* pParent = NULL);
public:
// Construction
{
class CConverterDlg : public CDialog
// CConverterDlg dialog
.galf deman elbairav naeloob a dda dna h.glDretrevnoC nepO •
.ppc.glDretrevnoC ni )(KOnO dna )(2oidaRnO ,)(1oidaRnO etaerc ot draziWssalC eht esU •
15. .tem reven si noitidnoc eht fi lla ta nur ton lliw edoc eht dna pool eht
fo gninnigeb eht ta srucco tem eb ot noitidnoc eht ,spool eseht nI :snoitareti tset-erP •
:serutcurts noitareti cisab
2 era erehT .gnipool eht gnippots fo yaw a niatnoc TSUM noitareti hcaE .)semit
fo rebmun detnuoc a rof ro( eurt sniamer noitidnoc emos elihw yldetaeper tuo deirrac
eb ot stnemetats fo puorg ro tnemetats a wolla taht serutcurts era spool ro snoitaretI
snoitaretI
.tsil detaremune na fo srebmem neewteb
hsiugnitsid ot desu semitemos era stnemetats hctiwS .yltnagele erom boj emas eht seod
stnemetats- fi esle- deredro fo seires A .++C ni detnemelpmi ylerar era stnemetats hctiwS
}
UpdateData(false);
}
float(weight * 0.02); cost = default:
break;
float(7.50); cost = case < 4:
break;
float(4.00); cost = case < 3:
break;
float(2.70); cost = case < 2:
break;
float(1.40); cost = case < 1:
{
switch (type)
else if (weight < 501)type = 4;
else if (weight < 251)type = 3;
else if (weight < 101)type = 2;
if (weight < 51)type = 1;
int type = 0;
UpdateData(true);
{
void CParcelPostDlg::OnCalculate()
.tnemetats hctiws a ni noitidnoc
eht rof desu eb nac )rahc .g.e ,tnelaviuqe rieht ro( sregetni ylno taht etoN .euqinhcet eht
esitcarp ot edoc ruoy ni stnemetats hctiwS esU .evoba nevig noitamrofni eht ot gnidrocca
)tsoc dellac elbairav taolf detcennoc a htiw( xob tide na ni tsoc eht yalpsid dna nottub
a skcilc resu eht nehw egatsop eht etaluclaC .)thgiew deman eulav taolf a ot detcennoc(
xob tide na ni thgiew eht retne ot resu a swolla taht )desab golaid( tcejorp a ngiseD
20.0*thgiew yb detaluclac era g005 naht reivaeh era hcihw slecraP
05.7$ 005 – 152
00.4$ 052 – 101
07.2$ 001 – 15
04.1$ 05 –0
tsoC )marg( thgieW
.sthgiew tnereffid nopu desab slecrap rof segrahc gniwollof eht sah eciffo tsop ehT
tsoP lecraP :6 ytivitcA
16. dnif ,redlof slortnoC deretsigeR eht nepO .)yrellaG slortnoC dna stnenopmoC ,stcejorP
ot ddA( unem tcejorP eht gnisu xobloot s’rotide golaid eht ot lortnoc peeB ruoy ddA •
.repeeB margorp siht gniman ,won draziWppA htiw margorp desab-golaid wen a etaerC •
.swodniW htiw lortnoc taht sretsiger osla sihT .xco.peeB etaerc ot peeB dliub woN •
}
MessageBeep(MB_OK);
// TODO: Add your dispatch handler code here
{
void CBeepCtrl::Beep()
.dohtem )(peeBegasseM CFM eht gnisu ,peeb
retupmoc eht ekam ot edoc eht ddA .draziWssalC eht esolc dna KO kcilC .diov epyt
nruter sti ekam dna peeB dohtem eht emaN .dohteM ddA tceles dna bat noitamotuA
,draziWssalC nepO .lortnoc ruo ot )(peeB ,dohtem eht dda ,lortnoc XevitcA ruo hsinif oT •
}
COleControl::OnLButtonDown(nFlags, point);
FireClick();
// TODO: Add your message handler code here and/or call default
{
void CBeepCtrl::OnLButtonDown(UINT nFlags, CPoint point)
.skcilc hcus eldnah ot reldnah-tneve kcilC
a pu tes ot elba eb lliw lortnoc siht esu taht smargorp dna ,dekcilc si nottub eht emit
hcae tneve kcilc a erif ot lortnoc eht sesuac edoc sihT .ppc.ltCpeeB ni lortnoC XevitcA
ruo ot nottub eht skcilc resu eht nehw tneve kcilc eht erif ot edoc ddA .lortnoc XevitcA
eht ot reldnah tneve )xob segassem eht ni NWODNOTTUBL_MW gnikcilc elbuod yb(
)(nwoDnottuBLnO eht dda dna bat spaM egasseM eht tceles ,draziw ssalc eht ni llitS .KO
dna kcotS si noitatnemelpmi eht taht kcehc dna )kcilCeriF fo eman lanretni na gnivig(
eman lanretxe eht rof kcilC tceleS .tneve ddA tceleS .bat stneve XevitcA eht tceles dna
unem weiV eht ni draziWssalC nepO .nottub eht ot tneve kcilc a dda ot deen ew woN •
}
SetText("Click Me!");
// TODO: Initialize your control's instance data here.
InitializeIIDs(&IID_DBeep, &IID_DBeepEvents);
{
CBeepCtrl::CBeepCtrl()
.edoc gniwollof eht tresni dna ppc.ltCpeeB nepO .noitpac a nottub ruoy eviG •
.ssalc peeB eht etaerc ot KO dna hsiniF
kcilC ”?ssalcbus lortnoc siht dluohs ,yna fi ,ssalc wodniw hcihW“ noitseuq eht rednu
unem nwod pord eht ni NOTTUB tceles ,2 pets ni tub ,1 petS rof stluafed eht tpeccA •
. tcejorP eht eman dna
Beep
draziWlortnoC XevitcACFM tceles ,stcejorP..weN rednU .lortnoc XevitcA ruo etaerc tsriF •
.stupni resu eht rebmun eht sa speeb ynam sa dnuos ot
pool tset-erp a esu neht ,peeb a esuac ot lortnoC XevitcA na etaerc lliw ew ,tcejorp siht nI
repeeB pool tset-erP :7 ytivitcA
.ecno tsael ta snur syawla edoc eht taht
os pool eht fo dne eht ta si tem eb ot noitidnoc eht ,spool eseht ni :snoitareti tset-tsoP •
17. .2 petS ni ssalc NOTTUB eht no ti esab dna draziWlortnoC XevitcA CFM eht esU .6 dna
1 neewteb rebmun modnar a etareneg ot )eciD dellac( nottub lortnoc XevitcA na ngiseD •
.desu si ti emit hcae eulav dees tnereffid
a sah ti taht os )thgindim tsap sdnoces ni( emit tnerruc eht ot )(dnars eit lliw eW .ecalp
emas eht ta trats syawla ton seod )(dnar taht os eulav dees laitini na edivorp ot )(dnars
esu ot deen osla lliw uoY .rebmun modnar a etareneg ot )(dnar ,noitcnuf wen a esU
rotareneg rebmun modnaR :8 ytivitcA
.margorp ruoy nur dna dliuB •
}
UpdateData(false);
counter = 0;
}
for (int pause = 0; pause<=20000; pause++) UpdateData(false);
counter--;
m_beeper.Beep();
while ((counter > 0) && (counter < 11))
UpdateData(true);
{
void CbeeperDlg::OnClickBeepctrl1()
.esu txen rof orez ot kcab xob tide eht tes dna 01 dna 1 neewteb
regetni na ot resu eht timil ot edoc dda ,nwod retupmoc eht wols ot xob tide elbisivni eht
ot esuap fo eulav yalpsid ot pool roF a gnisu ,)(1lrtcpeeBkcilCnO ot edoc gniwollof eht
dda woN . long epyt fopause dellac elbairav a dda ot draziWssalC esU .elbisiV tcelesed
dna seitreporP ot kcilc thgir ,xob tide na ddA .nwod ti wols ot ksat rehtona rossecorp
eht evig ot si melborp siht evlos ot yaw enO .peeb eno ekil dnuos dna suounitnoc era
speeb eht taht tsaf os nur sretupmoc nredom tsom taht si melborp gniniamer ylno ehT •
}
}
//terminate loop
//Changes loop condition to counter--;
m_beeper.Beep();
//counter condition. {
//A pre-test loop based on a while (counter > 0)
UpdateData(true);
{
void CbeeperDlg::OnClickBeepctrl1()
.semit fo rebmun rof deksa eht )(peeB llac ot pool tset-erp a esU .dohtem
peeB eht llac dna xob tide eht morf rebmun teg ot )(1lrtcpeeBkcilCnO ot edoc ddA •
.)(1lrtcpeeBkcilCnO
reldnah tneve wen eht dda ot kcilC kcilc elbuod dna 1LRTCPEEB_CDI tceles spaM
egasseM nI .tneve kcilC s’lortnoc peeB eht ot reldnah-tneve na dda ot draziWssalC esU •
.)(peeB.repeeb_m gnisu dohtem )(peeB eht esu nac ew woN .01 dna 0 ot seulav
mumixam dna muminim eht teS .xobtxet eht ot tni epyt fo dellac elbairav a
counter
dna lortnoc peeB wen eht ot ,repeeb_m ,elbairav rebmem a tcennoc ot draziWssalC esU •
”.speeb fo rebmun
taht raeh ot kcilc neht ,01 dna 1 neewteb regetni na retnE“ denoitpac lebal a dna tupni
resu tpecca ot xob tide na dda ,mrof ruoy no tresnI .peeB dellac xobloot ruoy ni lortnoc
XCO na evah won lliw uoY .esolc dna peeBC eman tluafed tpeccA .tresnI dna peeB
18. .ti nur dna srorre yna gubed ,margorp eht dliuB •
}
UpdateData(false);
m_text = char (m_button.Random());
can be assigned to the CString variable m_text. */
/*Use char() to typecast integer returned by Random() so that it
// TODO: Add your control notification handler code here
{
void CRollTheDiceDlg::OnClickDicectrl1()
.ppc.glDeciDehTlloR ot edoc dlob eht ddA •
.)(1lrtceciDkcilCnO
reldnah-tneve eht etaerc ot tneve kcilC eht ot 1LRTCECID_CDI tcennoc
dna bat spaM egasseM ot egnahC .1LRTCECID_CDI ot )ssalc eciDC eht fo( nottub_m
dna 1TIDE_CDI ot )tni na sa( txet_m dda ,selbairaV rebmeM>-draziWssalC gnisU •
.dekcilc si eciD eht emit hcae tluser eht yalpsid ot xob tide na
htiw gnola xob golaid eht no ecalP .)slortnoC dna stnenopmoC ,stcejorp ot ddA ,stcejorP
ni( lortnoC eciD wen eht dda dna )eciDehTlloR( noitacilppa desab golaid wen a tratS •
}
return i;
i = rand()% 6 + 1;
srand( (unsigned)time( NULL ) );
that the numbers will be different every time */
/* Seed the random-number generator with current time so
int i;
// TODO: Add your dispatch handler code here
{
short CDiceCtrl::Random()
}
;)tniop ,sgalFn(nwoDnottuBLnO::lortnoCelOC
FireClick();
// TODO: Add your message handler code here and/or call default
{
void CDiceCtrl::OnLButtonDown(UINT nFlags, CPoint point)
.
.
}
SetText("Roll the dice!");
// This line is to change the button’s caption.
// TODO: Initialize your control's instance data here.
InitializeIIDs(&IID_DDice, &IID_DDiceEvents);
{
CDiceCtrl::CDiceCtrl()
.edoc fo senil gniwollof eht dda dna ppc.ltCeciD nepO •
.reldnah-tneve )(nwoDnottuBLnO eht etaerc ot NWODNOTTUBL_MW
ot lrtCeciDC tcennoc spaM egasseM >-draziWssalC nI . epyt nruter eht ti gnivig
short
Random dellac dohtem a dda ,dohtem ddA >-bat noitamotuA >-draziWssalC nI .KO
dna eman lanretxe sa Click tceles ,tnevE ddA >-bat stneve XevitcA >-draziWssalC nI •
19. srebmun iccanobiF yalpsid ot pool tset-tsoP :9 ytivitcA
eht lortnoc ot retnuoc a esU .srebmun iccanobiF 02 tsrif eht etareneg ot margorp a etaerC
.pool tset-tsop a ni snoitareti fo rebmun
• eht morf( h.coDsrebmuN nepO .srebmuN dellac tcejorp tnemucod-elgnis wen a tratS
.noitces cilbup eht ni )2atad dna 1atad ,atad( stcejbo gnirtSC eerht dda dna )selif redaeh
• .stcejbo eht esilaitini dna ppc.coDsrebmuN nepO
CNumbersDoc::CNumbersDoc()
{
// TODO: add one-time construction code here
data = "The first 20 Fibonacci numbers are:";
data1 = "";
data2 = "";
}
• eht ni srebmun iccanobiF eht yalpsid ot edoc eht dda dna ppc.weiVsrebmuN nepO
.dohtem )(warDnO
void CNumbersView::OnDraw(CDC* pDC)
{
CNumbersDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
short x = 0;
short y = 1;
int counter = 1;
//Declare variables to
CString new1 = ""; //format the values as
CString new2 =""; //text.
do //Use post-test loop
{
new1.Format("%ld", x); //Format values of x, y
new2.Format("%ld", y);
pDoc->data1 += new1; //Concatenate to string
pDoc->data1 += " "; //Add 3 spaces
pDoc->data1 += new2;
pDoc->data1 += " ";
x+=y; //Change value of x,y
y+=x;
counter +=2; //Changes loop
} //condition to
while (counter < 10); //terminate loop.
do //This post-test loop
{ //concatenates values
new1.Format("%ld", x); //into data2
new2.Format("%ld", y);
pDoc->data2 += new1;
pDoc->data2 += " ";
pDoc->data2 += new2;
pDoc->data2 += " ";
x+=y;
y+=x;
counter +=2;
20. }
while ((counter < 20) && (counter >= 10)); //Displays strings on
//screen – each string
pDC->TextOut(0, 0, pDoc->data); //on a new line.
pDC->TextOut(0, 20, pDoc->data1);
pDC->TextOut(0, 40, pDoc->data2);
}
• .nur dna dliuB
spooL ROF detseN :01 ytivitcA
a htiw 21 – 1 morf selbat semit eht yalpsid ot spool roF detsen sesu taht margorp a etirW
.elbat semit hcae rof enil wen
• .selbaTnraeL deman )exe(draziWppACFM htiw tcejorp elgnis wen a nepO
• ,elbairav gnirtSC a eralceD line
.h.coDselbaTnraeL ni ,
• ( ppc.coDselbaTnrael ni ezilaitnI line =” ”;
ot edoc gniwollof eht dda dna )
.ppc.weiVselbaTnraeL
void ClearnTablesView::OnDraw(CDC* pDC)
{
CLearnTablesDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
int i;
int j;
int y = 0;
CString convert = "";
for(i=0; i<12; i++)
{
pDoc->line = "";
for(j=0; j<12; j++)
{
convert.Format("%d", ((i+1)*(j+1)));
pDoc->line+= convert;
pDoc->line+=" ";
}
pDC->TextOut(0,y, pDoc->line);
y+=20;
}
}
yhpargoilbiB
.xebyS :ocsicnarF naS .emit drocer ni ++C lausiV .)8991( S ,renzloH
21. drofpmaS yelreveB
yb deraperp saw krow sihT
mth.golatac/ten.de-eerf.www//:ptth :golataC esruoC teN dE-eerF
.tteltraB dna senoJ :sttesuhcassaM
,yrubduS .++C htiw gnivloS melborP dna gnimmargorP .)0002( .srehto dna N ,elaD
secruoseR rehtruF