Marco Cantu

Delphi 2007 Handbook

Pia<:ell7.a.lt,I)",Junc-September2oo7

toLdia,theio;""ofmylifc, oncitollcnedettaandJaoopo, ouc IO;'e oome to life.

Marco Cantit,Oeiphi 2oo7Handl>ook

Mar.:oOmhL,l)ell'hi2007Handbo<:.k

Aek""",k-dgrncnIS·S

Acknowledgments

, Formoce;n\onna'ionJbo<HBn,,,,F.ckor.,,or\;,,,,,,,I"'p:If"",,",m;,Kh-ie,,-.nct.for mo .. ,bou'J"I;"nB"O\:".II=hllP:II~"""',bo;.et.co",

Mareocan,il,DelphI200711a"dbook

,\cknowledgrncnrs.6

lislS. indudlng Nid Hod~.Jason Vokes, Malcolm GC'O\'CS. nnd 1':1",,,1 GIo""cki. Sreeialtnnnksgotomyfricndsal1dDclphiexl',erts(woll,mOSloflhcm)BolJ Swnrt.Andrea P,o'"Slio. Nornl Mclntash,Jo.1l1nn Poolcy. Rny Konopka, C;uyJmlSCn,Brinnt(",g,H()lgcrf~ick.CnrisFrilWllc,Mi"h"cll.1nl,Jo.1nll3 C;>rtet,JimCooI>cr,Ch,isH""Cross,JasonSomhw"t1.01.,fMonicll.Hmli Hatiti.Chad Howcr,MikeOrris,Jcroen Pluimcr!i,F"brbdoBit1i.ancitlle en· tireltali3nDelphi&DintomiTcrun, Fortheartualpmductiolloflhebookl\-ebadnlolofhelpfrommyeditor PetI!1'WDOd3ndt""hl'C\~el\'C'rsHolterF1ick,Femnndo~13druj:a.Se<tio Sclle. MarroBI'C\·cdieri.3nd [lOtspeci6c portions) NaruJo Oes;en, [dbl'Jc· pn:ssj.PierreleRicbe{mernoryman3ger),andSinanK:trarn(lnstollA"",ej. Th.bco:>kyouarerc.'ding"'ouldh"''Ch"dm~nymoremislllk<'Sandmi$Sing

dc[.,ils,ifit WlISn't for their hdp .

IlIckingthcform"lnI'Jlr""ch(andmo""l'jofnllcs~1blishet.ipuhlish"rIhud Insto,,1 around for~"nilnblc JI<lOplc .. ,and offcrsomcoflhcm limiled deals Ci'"En m}'uou-e.<istcnt&,"phi<alabilitl',andsi~rel "",,tet.i 10 hayca nice bookco'....-,lbenelitoorromlbehclpofgraphi<dcsigru:rFabril<ioSo:bia'~' ",bodcscrihe$lbe(.'(l\'CridcaaslOllo\.s:

-r W<lntro somerhing roferring ra narure. bmalsoa marhmnariroi rofer. enceo:mmxlingirrorompllrcrscic,"ce.Therejore,lduplirorrolhcbirds w;i"gtheFib<>naCC;S(_~luc"ce,·

Man), tnnoks go also to Ihe p.!oplc who share my we,klood nl my Imilling anrlconsliliingcomlhlny.Winlrehllali.1S,I',i'aolonndMiohQln.FiMll}',I could hO' ,vn'.'hisb""k",i'h~,,,·",,,,,1ing"p,,,,,io,,,,'\m~r,,,,tl my"'i("",,d ram;ly.soif)'ouCllnre.ldlhisyou·llba,'ClojoinwilhmeinlhankiIlJ;Lella, Iknedetla,aodJaoopo The6nallhanks.asyoumighlha,,,secainp,,,,iousbooksofrnine.arefo, alloflhepeople(atalliongiludcsandlatitudcs),mnnyofthcmunkdo"n nndnnnoticed,,,·hocnjoylifenndhelptobllild.bcl1crworld.Dropof,,,,· terafterdmpofwater,andyouhelplumdcsert;inlog:ordcll$;I",,,gesture .ftcrlon,gesru""youhdpbringpeaoelothcworld

J M"""nd""'''''lf'.,.,...;bt.inro",""".,.bomonY'''''n\,,,,"ciOO",,uh;ng,,,,npany"" \::;~"" •• hnp:ff"",,,,·.""'t«h.itali>';t.W.<II",,,,,~.also"UCadoG<.rrprod"""i"

l'o1an:<tCantU, o.lpbi:lOO7 Handbook

Inlrod"01'0"-7

Introduction

o.'e'lhcla.<;lyca"CodeGcarha.<;rdocuse<!onlhtproduot,bunohingthe freeTurooE:<plo",,"""<sion,roil\\'igor:llinglheR&Oleorn,g"lling'n"h' prod"ctm"n"ger,l'lin.~tofigureQUllhe,uslorncrneeds>andn:l=ing3 I!ew\'e<sioo (Dell,hi ~007) in reeord timo, Indeed, a.onClenm memi)L>r suggested,itisa"Delphilten,i"",ncc':

From Mastering Delphi to this Handbook

AfterwtilingB Mru;leringDelp],ibooks,I"'cc:omC'olhedecisionlh,1 lite Dclphic:ommunityneedssomclhingdifferenl.R.'thcrlba"writing"n~1I-

~ This..,..~' ..... Sh.,,,y,no5S)','''''p' .. '''nfi,><l'h·bIospo<,·t: h"p=/fbIo&s.«>dcs=.rom/"",..,.h,"&!mOS<j·!.",hi,,,!2007!OJ/:>'/33:l)f>.a<P<

MarcoCanh',,Deiphi2007Handbook

encompass;n!; book, ....,''Cring both inlrOOuclar), ~nd ",h,mC'Cd male",,), I lhinkilm.,kcsmorescnselOll'rileaboakfo<usedane!:isling~enced DclphidCl'Clopers, l'I!;ma"yoflll=d",'elo[>Crshnvenlisil!dthel(l.';t~Ollplcof"ersiot1SofDcl phi,thcaimoflhebookiS1ohri1lSlhcmUplOS)lIlcdco\'cringlhemosl impon""lfeah,,,,""ddl>d.illCCO,,lphi7.Inmo'tC"SCSlhcmalMi.isoos inlosomedepthasilisnOlmeantforbeginners.Somcoflhcnewl""hnola· gies,lhou!',i>,:troonlybricAy<O\-ercd ... a ... "yafintrodOClion. Inlheboaklhcreateso,""referenoestornalerialin M3l;leringDclphi 2005 (",rillcnbyrnl"Sclfandpob)ishedbySybex,nowan;rnprinlofWile)·).lbere isalolfrornmy·Dclplti2006UpdlteEboak·(freelya,,,iL,bleonline.,rn)' ","bsile),and"dea,fo<usonwltat'sn"win[)ciphi ~OO7for\\'jn3~,lhe \"ersionofDelphilhatlhisbookisfrxusedon.'Thil;nlsoimplieslballhil; bookexdllSi''Cly<o"crslhe!)cJvhiWill3~l'''rsol~11ily8Sildoes.lmighla, wdlcomellp"ilh'S]lecir.c!)ciph;for.NETbook,blll!lilillklhaloncof Ihe.d,,,magcsofnsmnllcrpllbliealionshonldbcilsfoclls.Tltefocuslwl'Ci" Win32 deo,'elopmcnt for Windows 2000, WindowsXP and Windows Vista, lbelhrccplotfonnsOelphi2007<>ffi<i.U),su]l»Orts.

Formatting and Conventions

This book il; published in Lulll·sCfQ1mQIl3r1oFormot.7.44"x9.6S·. I w;ed lheGcorsiafonlforllLcl~xI,nVerdanafonlforlhchcad;ngs,.ndal,udda Consolcfonl(lhcSIlmclusebydefallllinlheDcl]>hilDE)forlberode:

1//rMs;saSil",plec~nt

Rookcou'·Cnlionsnrc'-elyiimited. Ker"",rdandS),nbQl Il(Imesinlbele:rl nreinaspecialfonl,al;in,-Objenislhebasccloss-.lde<:idoolousefootnolcsnltb",llianin·)inenolosaslbey$houldbelessdlstm<:lh",froOllbe le:rI Row. Allbe$1me l'Ole, using foomoles I felt more f"", 10 add ""!nII""1 andpersonalanno,.,ions,,, ... obsilerefcrenre;.andmon:.Manylechedilor commeotsendedupinuOI('S.

1"!md,,~!i""·9

Examples and Source Code

A-s it is !me for mYl"'"'t books. there"ro plen~' of <'."""'ples you ran lc.,m rrom~nde.peri",cnt";lh.·11,cIlX3mplcsdiseusscdhercarc(rrol)"a,,,iI.1bl{! onlinc.Yo"11findthes"""ificaddress(orlhcoodcmtltem:tinpagcof,,,)· sitedC\·otedtoth~book:

I http://~''w.,,,,,rcocantu.cOlll/dh2007 The!iOlln-.::oodcfortl,isbookisrol')"rightedrre.::,,~ro.Thct'Ol')Tightl're".ntsYO\lrromrotlllbli.hingthemdeinprinlmedinaront!tclntert,cl "ithaullhcpriorl>erm~,<;ionofthea"lhor.

Seminars and Consulting

il""chntW\Hlay"!'.1ig'""tingloDdphi2oo7"S(!n,inaronsltealroml"'IlY 1000tion""'orldwideor"tm)"oon,po")"silcinltal)"."h~dass""nooindud· edinalongcrlmlningse:ssionaooC<)' -e rill&manrda..<sicandad, .. nrro Delpnitul'ics.rromdolao=lodynnmicnrcltilrolurcs.froma,i>-anced language topics 10 X!IlL ond Webdc,·dOI''''cnl in Delphi. R.efer 10 my well silefor'norodet"ils.Onlinesemino<sarocurroutlyun<icrC\":Ih."lon

About the Author

~l)"namc i.~ M,m;oCanli,. 1"", Iltc2uli,oroflbe I:>csc.sdlillg ~1"'terinS Del· phlbookserics~,Id]"mC<)"s;dc.ed3prom;ucnlfigurej"lbcllclphi t'Ommu";I}'.lw;u;oneorll,cn-.::ip;~ntsoflhe-SpiritofD<:lphi·a"":Irdin 1999. logl1herwith Dutoh l)elphigun,t).o!}S"'lIrl. 1!"",h~ndooll""II()uDcl1'hi,"r.d.lsoanXi\ll·rel~ledntldWeb2.0!"",hnologics.osj"outanl"'rtlallyseeon m)"A.)AX-foeuscd ""bsilC:

!·http://ajax.m~rcocantu.com

Mrm.'i"l\'cltsllC.tnO$ll)"C<)'....,rill&book<andDelphjI'Togr:llnml~.l"m:

Ihttp://,,,,,,,.marcocantu.cOO1

Myhome-gro""I1"MarroTecl, tHol:"~allbcfolllld31 Ihttp://blog.marcocantu.com

M"rC<)c..nti'.Oclph;~007Hnndhook

Contacting the Author

andoverthewebathcURL

I ht~~~~~~~~~~~~~~~5what. com/geoxml /forum 1 i 5tgroups?

Thisisanareo whereonlylcan,,"ritc, not a real ne'>l'sgroup, an<i where yo Ll canalsoflndmirroreddownloadfileswithbooke,amplesandthelike

Looking for Tech Support?

Che<kouthttp://support.marcocantu.comformoredetailsaooutthis brnndnewoffer.

b Tofig""',lUtw ...... mnownisandseesomea<riatpictuL"<!S)·o""'n'.r.""OOO!lI.

M.p' •• 'llttP'llmap,.gQ(lgl •. "'rn/rn'p>!~.p;,"'n"'.;t.~,.

7 11leNNTP .. m':""",apa",~.,,,d,h,,edh)'.lltlSOl'Stop,,,,·enln"".,.groopspam.

MaITo CantU,DeJpbl 2007 Handbook

Table Of Contents

Aclmowlcdgmc!lts. .....•

MarcoCauti',Delphi2007Handhook

iVlarcoCannl,I)<:lphi2oo7Hmldbook

TablcofConlenIS.':J

Ma.-.;oCnntt"l)ell'hi200?Ha:ndh<>ok

T"bleofContents·'4

Oth...-NewRTI.Frolu= , .

Exe<ulobIeSiz(ound<!rtileMi<ros<ope.

. "6

'"

!I-Iarco Cantii., Dell'h;:>007 Handbook

l'al>lcofContcnlS·'5

MarcoCantU,Delphi2.o07Handhook

TnhlcofComcllts·,6

PostscripT ....

Mnn:oCanlil,o.:lphi2oo7H"ndhook

I: The Oelphi 20071DE-l7

1: The Delphi 2007 IDE

Matco CantU, Delphi 2007 Handhook

"'I1,,,Delphi2007IDE_,S

A Short History of the Delphi IDE

TheoriginalDclphiIDI\,(h;llworkedulldcrWindOIl'S3.1.pro\idedthe gl"Olmdwmkfor;l11 fnllowi!lS \'er.;ioDs right ul'lo[l(,lphi7,Aroulld that time, Borland dccidcd(ore<lesignlhcIDE toopenit uploO)ultipleprogrnmminglanguages(orperson"litics.astheywcrelatertalledl,tosupport NETd"""iopment.nndtoinlegrnteSC\·craIApplicalionLifetimeManage_ ment(Al.I>l)loolsthcyh~dboughtand""{,,.,foollSingon

Theso-ealled -G.liloo- project isthcfoUlldatiob of~1I receol Delphi IDEs, fromDelphi8toDelphi2oo7.ForDelphi2oo5andDelrbi~oo6theIDE WlIS <ailed Il<>rland DevcloperStudio(BDS),in Dell)hi ~0<l7il is called RAil Siudioand is now proou(-ed byCodeGear D"ljloi2oo7j"thc5"ver.;iunoflhcGaliloolDE(alsoi"dudin£theo~in"I C#Builder)andili~lhcforstDelphiIDEprodut~II))·CodcG ... r_Delpni 2oo7isalsolheforstIDEwithacw..slibrarysp<.'<'ificaltysupportingandtar_ getingWlndowsVist~,butlMt"ssomethins["IICO\..,rindelnilinCb3Ptet9

A Single Personality

AfI"rreleasingDelphi2006asa-SlUdio-\"etSionc~COml''I-",ingmultipl" person.lities,CodcGe"rhasno'''rclea.sa1Delphi,007for\\,in3~,whichis anupdated"ersionorthe:l.1meIDEwitho~I}'o"cp"rso,,"li!yi"Slalled_Tf yo" "ced 10 do Delphi Fo"NETd"_'elopmontoruscanyofthcoloerpro gtammiug languag<lS ""pponed by Delphi 2006 (C++ and Ct),you'lI nced tokeeporbuytbeoldCT,'crsion_Ncedlesstosay.tbelwooaoooiruttaUedon thesameromputer,asbas.l.,."ysbeetlthe<aSewithdiffcrent\-er.;ionsof Delphi Tobe.bsolutelyfaolll.111ycolTOCl.!heremighloo.fawSlob.llibrnriesin_ stanediDWindows\Systcm3~lhalmigbtbercpl"ced"hen;nstalling.tle"" ,-mionofDelpbi,socbastheMidas.dlllibt.l!)'.They3rcMtk-wardrompati_ ble, lml there mighl Ix:sublladifferences, ,\Iso. due to Ihcfaci you w .nlto endupwithtbelnleslversioll,itisadvisahletoin"!,dl,liffercntversiousof Dclphiiotheorderthqwe",re~d(for",,"mplc.Delphi7,lhellDeiphi 2006.andlinallyDelphi2oo7).Moreo\"er,thehin"ll'compatihiiityofDel_ pbl~0<l7withDelphi2006migbtcauseaf""'troubles,nsdisc.-ussedbelo"-,

M8r<OCantiJ.Delphi2007HII"dh<>ol<

o:Thel)<'lphiC!o07JDE-19

A Non-Breaking Version

Forlhcfirstlimee<.-er,Delphi2007isbi""l)'comJ)<llible";lhlbepreviollS version, Yes, asod<iasil mighlSCIund loexllCricnoed Delphi users, Delpbi 2oo7isbinaryrompMiblc(DCUandBPLcomJ).1Iible)";lhDelphi2006, Diff.rcntlyfromthepas!,)'o"cnnlinkaDcll'hi~OO7apl'li<alioulhalusesJ coml'iled unil (DCU) buill Wilh Delphi2006,Nol lhJl this witl bccomc the norm,astilcnc>ctvcrsionislikeiytobrcakthcbin"ryoompatibility,but with TIlorcfroqucntycrsionsbcingrcloascd,it""kcssenscto",akesomeof them coml'''lible to reduoe tbepmhlcms"ith Ul'tWling 10i,d p"r1)-rompo-

l;,-eniflhcrearcarcaslikethcne\\' [)BExl'f<SSlibra!y,lhalcouldnotbe co,npalible, most of tbe cbanges in compiler, nlntime library, and VCl were m3de,,;tbgTeatcareto"widcbnngingtheunitinlerfucelioawaytbal wouldbreakoornpat{b;lil}'_M}'Ournnseeintl,cForms.p.1Sunil.forexampIC,lbcR&DleamhadlopulinsamcextrnefforttoaddpropcrtiesO;kelhl:

CI;)SSsupportj";lboulchangingtheforms,]'UC(\\-eTthisspecificca;ein moredeL3ilinChapteT8 Wh"lisrelevanttonoleistbattoobtainbinarycompatibiiityCodeCearreplaocdsomeoftbelilesoftheDelphi 2006 ronlimc PJck.,ges with new ""r"iuTtO.Thi.m"ansthatinst"lIingDdjlhi~oo70.'n.ffectlbeDelpbi~oo6 IDE (m,d it did causesometTollhleslikOlilcmis;s;tlgToskUaruunonupon Dolphi2oo6startup,atleastuntil the Updnte lofD~lpbi2oo7was,e- 1~"ood)_The""meeanhapllCntoyo"'"I'I'Ii<atio,,";rth"l'useruntime 1"'ok"5"" ""d lhe<on=pomli\\~ BPI. roles ,,,.,,,,(\oplo),.,d in .he WindowsfS),slern32foicleT.AnotJoerapplk.,tioninstHllingupdatcdDelpbi 2007paokagescoutdaffec1 thebehavLo,of)'O\lrp,ogrnrn. Had)'ouinstalleit theruulimepaokagesintbeal'plioalionfolder.tbcl"'oprogrnmscancoexis! ande-·""runs;debyside.

Installing Delphi 2007

ThcDelphi2007insL3llationsequenceisquilediffurcntfromtbep.1S! The,eisa.ingl.i",taliationDVD.indudinsnlllang'"'gesnndedilions.B)' providingtbcinitiallicensckc)"liocinSlnl1cr<ictcrmineswbicb",,,,iontb"

~13rt_'''C<n\''',Delphi,,007Handbook

I:Thel}eiphi ~oo7II)E-20

Moreinformal;onai>olllthcln.<tallAwarc;,,-,taller(mOSllyrelatedtDusing thclighl\'ersionindudcdin Delphi2oo7jisinChapterlLCodeGearisho,," i"gtobeahlelouselhisne"'installertopusbelec:troniclkensin~n= physkalDVDstobe~I'ippedJandtobe!lermanagelheinsl"lbtioDofupdates. p""iously,!uilemess}·,,;th formal up<iates. bot fUl .. , boc fix roUups, aodmo",-WithDelphi~oo6de\·elope<shadlofoliowne",.gro",,"aDdblo!;S lofigureoutwhichopdaleswcrea,"ailahle,whens--;tthingloDelphi2007, theIDEisoowcap.1bleofdOl'"loadingopdales

The New Folder Structure

After installing Delphi ~OO7you<aD Doticel"allllcso~wareisinslalledoD }"ourharddriveinadifferentloeationtbaDintbepasl.8IIcastifyoupiek thedefaultinst.U.'lionfolden_Afewcbangesba,-calrearJrtakenplace,,;th previousG.liIeo,~ions,bulDelphi~oo7istbefil'St,"crsi<>nlb"tiostails properiyonVisUsuPl>oninglbe-Umile<lUserAeOOUnlConrroj"(Limiled UAC)ruIes.AI;we1IsceinCbapler8,bydefauitVist"docsn·lallo,,·pl"Ogrnmstousethefi1esy:;tem al "ill,limitingacoosstokeyfoldcrssucbas Prog,"mFilcs.

Tbeotherreaoonth"t"ffucled the Delphi installation folder strudu,e istb e d,a~~e in tn. ~amc()fllte companyo""i,'S ,h. proonct (from !lork,~d to CodeGeru-)aDdtnen"meoflneIDEitself(fromBDStoRADSrudio).Thisis whrthemaini!lSlall:!tionfol<krinDeiphi7was: 1C:\PrograooFiles\Borland\oelphi7

in Deiphi2006 it ""3S

Ic:\programFiles\aorland\BDS\4.0

.'nrlinDelphi2007itis

IC:\ProgramFiles\CodeGear\RADStudio\S.O

Recenl'-.,rsiOllsofDelphiol<omovedtheP,ojectsfolderFromtheProgrnm Filesareatotheuser·sdocumontsarea.Thclatcstversionalsomovestbeex.mpiesaudotherconfitur.lIioofiieslolheuser·~"h"roddocumentsarea

MoreoContu,Delpru2oo7Handbo<>k

ThisisasunlnlaryofmOSlrelel'aIllfoldersouWindo".,;V;,ta(use,sfoId"" have a different phy,ioalslrLlclure;\I Windo""XP)··

Ic:\progra" Files\codeGear\RADswdio\;.O

Ic:\programFiles\commonFiles\codeGearShared

Running the Delphi IDE

Marrocanll'.I)eI(>hi2001Handbook

l:Thenelphi:!""7IDE_2:!

The first timcyOllru"it.Dclpbicreates. brnnd"",,·sctofrogistlyke).,.,115' ingdef"~ltsct\;ngsfrorn:

IHKEY_LOCAL_MACHINE\SOFTWARE\sorland\BDS\5.0 nndcopyingtbc",illto:

IHKEY_CURRENT_USER\Software\Borland\Small\S.O lnotherwords.tbenarneyoupro\'idoreplaces the BOSnome;ntheregi.try tree". If}'ou don't "'"nt tostnrt "itbbrandnewseuingsbutedit}tmr<:nr_ rentoonfigurat;on.e>:porttbestandardBorland\BDS\S.oA'gistryke)',edil ittocbangetbekeynamc,nndre-impOrtitintheregislry.Aniretooilo h.ndlemuitiplestanupsccl!.1riosisJeremyNorth'sDelphiConfiguratioD Maoager,wb;chcanbefOlmdat:

Ihttp;//""".jed-software.com/dcm.htm

-ns (nosplasb);disable:s lhcdisplayofthesplashsc,ecn

-np (nopage): disables the Welcome page

A New IDE

Fo,examp!e,therootento(theStruclureViewis$imila,totbatoftbeObj"'tTteeV.ewofDelphi7wbenadesigaerisacl;\"e,whileitrescmb1esthe Code Uplorer",benyou are """king in theeditot.The most striking differ· enl is intb"Tool Palettc,whitb replorestheCompOnentsPalenebutcan aloocontain llieelemen\S of the Ne",ltemsdialogoox(oblained",ilhthe fileINewIOthcrmcnuoommond)whenyouarowo,kingontbecode.

,oY oddly.no"ghtbe~'Y .. ;II,ef.r."o·Bodand·'n<I·BDS",Prob;bl;·fu;ngall

"" m.......,..~ouldh"'~""....,.p""'lem$toth;rd.partyplu,in'ooIsfor'he

Delphi!DE.

MarcoCantU,Delphi2007l1andbook

InlheRADSludioIDE,mostpanesaremoren""ibleandbostdifferenlronlCnldcl"'ndiDgoDwhaltheuscrisdoing,particularlywbicbDl3iD"indow )uuare"urkingoD('isualdesigllCf,edilor, U~IL'icwcr,and""on)_For lhisreason,itbkessometimctogctusedtOit.lndccd,somcofthenewfea tures<alloodi .. bledandyou""nreo.-ertbacktotbe·undocl~-mode (simplypicktheClassicUndockedlayo\ltintheL.,youtscomboboxtosee howitlooks)_k;theIDEtendslohequiteprod"ctive~fterawhile, [suggest you tryouttbenew!ayoutatle.st unlil YOll sot wicd tuit

A Themed IDE

ThclICwlDEisthemed. ltlooksrnl>Ch better, particulariyon V">Sta but also undcdVindows}"l'.YoucandisablethethemcsintheIDEbyaddiogaountl,cn,edbduxc_m(mi{e!;tfiletotheDelphibinfolde,,,,,drestMtingtheIDE. Aswc'lIseeinChapter9,iiyouturnonthcoorrespondingprojectoption yu"canseethcformsoftheyo",prnjectsthemcd"lsoatdesi~ntimen.This isa,;ignifi<:antdifferencefromthepast

The welcome Page

As you run tbe lDE.yourstarting point "ill betbe Wcloome page. TheWe! comeJ>il&'isapanehoslin;lntemctE.plorerandallowingyouto"i",,' someper!incntinforrnationandbrowsetheWebaswell.WhileinDelphi wosand 2006theprimegoal of the Wclrome page was to read RSS feeds (sometbiogl'd"'tberdo"ithaspOCi~ctoolorageneri<lI'ehBro .. ""r),the fucusinDelphi200]istomanageprojerts.

TI,e moot receot project:> you\.., opened 3re listed with some details (indudin~thelocatioDandtbelastchange), hut you can .lsosawyourfa'1>rite projectsandammgethemwitbin F.",rite Groups. Clioking on themanage Favoritcs;ntheWeloomePagetakesyo"tolhcfa'1>ritcsmanagementp"ge.

"l"olll""..'od.,..."d""'fH'I"hOI,,.o_jocti,,,III,IOE'o,",,blctl,.,,,,,,,atdosignt;me.

MlIrc..,c..ntit.Il<:lphi2oo7I1andbook

l:TheDeJphi2007IDE_:>.j

InthetopmenUlbC'fCareSlilllinksloRSSfeeds.productupdales,online resourres, hclp, and documcn!alinn files_Since I starte<i using Deiphi 2007 IgenerallykeeptheWciromePa;;eopen(displa};nglheProjcctpHgcjand dOIl'tdo<;eilasl used lodollith past "ersions.

TbcreyoucanfindlheooreI-ITMLandCSSfilcs.alongwithlheimagesdisplayoo,plus3lotofJ., ... $eriplrod",theXML-bascdoonfigurn.lwofilesfor tbcmenusandtheRSSfeeds,3udtheXSLTo:xIeforgcnerntinglheHTMI. from lhcfeedsan<i the projeclS lisI..

The Delphi Editor

TbeedilorisprobablytliepartoftbeIDEyouspenrlmostlirne"ilban<iitis alsotbeonelhat .. wtbelargestnuml>orofrcalandsignificantimprm-ementssince Dcipbi7. Compared topasr ,-er.;ions,assoon as)"Ou open an Obj""l Pascal sourcecocle fiieyou will notice thaI thereareiinenmnberson thesideoflhesourceeo<!c,afeatureyoucandi .. blcbyturningo!ftheoorresrondingedilorsctting !nsreadufoeeingthe""mhcrofeaeh'lldeveryliuclikcitlllclphi2ooS.you seeonlye"er}"tenthiin",withnhyphenindi""tingthcinrerlOe<iialelilies (evel"l'fifibline),andnsinglcdotfortheolhcrs.Theoniyexceptionislne line with Ihee<iil<u!$Ol",lI'hi<hh.;;thelinennmberdil;p!aye<i. Hereisan example(lbecurnorisonhne'7):

lI1areoCantit,Oelphi2007I1andbook

Eesillelh"""-is,,,,lclcments,lhemostuscfulch'''gesintheeditorarerelaledlo"","e",lcode,";tinghel""rs,fromBlockConll)lctiontothenC\,-L;"e Templates, whkh will bc"","Cred in deta;1 in Chapter~. Notice that m<»tof tbeseJre>\'f""rurosarellOtact;,,,tedbyshortcutke)'S}'Oub3,-eto!earn,hut showupautomaticaU)'asyQutype,beingtriggeredbysimpleke)'SlikeEntcr,theSl"'ccllar,ortheTab_Ha,-ingnewfearuroscmbeddediuCode Complelion(mam.,liytriggeredbyCtrl+Sp.1ce.butoftendispbyedauto· matioally)ismuchbettcrtb"nba'ingtoin"oke"SI>ccificrcqnest,likeyon hadtodobypressingCtrl+J\\itbtheoldCoJeTcnlplllles(amud,lessiulu itivesequcnce)

Code Folding and Regions

SiaceDelphi2005.theIDEall"""y()Utofold(orcoU~,,",,)anydedarnlioD, indudiogdassdecbrlltions.mcthods,orentire_tionssu<hostheimple-meDiation section of~ nnit. What's important and the "lOin reason Ibis fcaturewasintroduced,though,isthotyoueandefon"cnstomeollapsibleregion.usingthc SREGIOtI""J SENOREGIONdirectivcs(which look like L"O"'pilerdi,ecti,'<)S.but"reactuall),igno,edhylheoompiler) Forexample,intheRegionsTeslprogrom,I'vewrit\cnth.followingcooe"

1~;R::~:i~e:: :e~nt to hide by defdUlc

C~~~~dure TeStMeSsage; ShollOlessage('Test'); end;

{$ENDREGION}

"Th._w.}"to"-';"'th=t~'Odire<:ti> ... i:;to .. Iect..,'''''t'''''.nd'''''the-,.gion~nmpb., •• "'ilh'heSurn>und"""'mandof'heront"'nI<nuoftbeed~or

lI-IarcoCantit, Oclphi 2007 Handbook

J:Thcl)cll'hi ~oo7IDE·"6

Whcnyonopenlhefile"ithlbisrocle.bydef3ult,youllseetaissectionfold· ed"itha<aptioncorrespondingtotbestringprQ\idedintbeSREGION dire<1i,'e·

Youc"nen~hleordi",1blcfoldingwiththcBI)S/S.o/Editor/OptionsfEnable ElisionsregistrykeyanddeterminetbcautomaticcollaJlSingofrePoD blocksinnlesyouopenv.-itbBDS!S·o!Editor/Options/AutoColl'pSeRegionBlocks.

Thel'enl'ealsosomen"",sbortcutk~ .. )"'''''''nuse''';tbregionsandfolding, including

• Orl+Sbift+K+Otoenableaudclisoblecodcfolding"

• OrI+Shift+K+Etocollap;>ethcncareslblock

• OrltShift+K+Utocxpm,dthencarestblock

• Orl+Shifl+K+Atoc.pandallcodcblocks

Source Code File Encoding

In Ihcpasl.theDclphie<iitor.Uo"·e<i),,,Uto"",rkoniy"ithANSlsource codefiles.I-I'hiletbisisstiHtbedefuultfortUlltofthefilesyouproduce,the codeeditorintcmally".,>rks"itbtbeUTF·Sencodingandsupportssaving ancicon,'ertingfilesinanumberofformal$,;ndud;ngUTF-8andUTF·'6 ,..;th l.ittleand Big Endian tnOOe. You can usetheFile Formatsubmenu of

theeditorcont.,.,menutoch.ngethefilcform.' .

M8r".,CarlU\,[)eJphi~oo7Handbook

,,'!l,eJ)clphi2007IDE-27

Fore.<"mple,}'ou~"nusethestringBorland.FileFilter.UTF8TOUTF8t0 use ll1:F8 enooded fil"" by dcfa"ll

Sync Edit

Editor History

Mar<oCanlii,Dcll'bi~o07Ha"dbo"k

':Th~D~lJlhi 2(>071OE.28

I ~~~~~~:~~~ :=~:

Yonc""reopenthesefile;;withan\'(extern.l)edito,arbruwsethcmfrom theHistoryp.1geoftheIDE. Th;sj~\neb""threcfunhers"bpane;;

This is a.up",iJ,lo\\'·rost fileeomparison utiiitywrittenin Doiphi and cap" blcofunde"tanding",'cnbin_,ryDFM filcs, ADelphi'5pe<ificversionof

MaIToCantU,Oeiph;"o07Handoook

,,'1'cD<:lphi2OO7lDE-"9

thi<toolwnsmndea,,,iL,blca,n freedawnloadto Dclphi 2006u",,,,, Furthermore, there is an integra!ion package)'Oucan r.ndn!:

Ihttp://,,,W/,jed-software,com/docs/hc_readme,htm

Other (Recent) Editor Features

Tberenremanyotherbrnndnewfcaturesin!beooi!or,,'Orthmen!ioning briefly, iD caseyou ha'"nl noticed them_Here isa sumnl.1'Y·

• 11-13lch;ngJ>"n::nlhcs;,..As}'Outypeormo'"around!hecode,the editorsbowsmatchingrarenthe;esnndquo!es.'lbislong-a"'aited ~~::e isa !imcsa,""cwhenyou have code with mOllY nested paten-

• Macros.Thomncrotooiharattheleflofti>e.tntusbarattheboltomoflheedilorc.1nbeusedtorocord"ndrcpinyidc'tllical sequenooofkeystrokes.Thisfeat\l\"ewnsalre.,dya,,;).ilableinthe past";lhtheromlSpondin!';sbor1rntk")s(Ctrl+Shift+Rforre«>n1- ing,CtrI+Shift.Pforplny)_Editormac","",,"beusefulfor ""rfurmill!;mulllstcpo""rntioru;overando'"Cr"&,,in.sucb3Sreform,uingsou,,,,,codeorarrangingd,lamorclcgiblyinthesour<:e

-.

• Per .• islentB<>okma.k$.TheeditorMws.weslhe\>ookl\,arksyou se\,longwithothcrprojectdcsktopscttings.Thismeausthehook'Mrkspc,..islh<!I" .. nediljngsessions."l\likein)~1st,=ion$of Delphi_Bythcway.\>ookn,arksarecrenledusingClrl+Shif\plusa numberkeyfromot09,asyo\lllseeina"guttcrmarginonlheside ofthee<iitor.Tojumphacklothebookmark,presslbeCttlkeyplu" !benumfieri:ey.Toseealistofacti"ebookmarksyouha'·etoinst3ll athird.""rtyplug;nlik.emyownCantooIsWi .. ,rd(seeCbapter,,).

• Toggle Comments, One ofmyf3,'Oritencwfentures is the Toggle Commen! command, whicb is ,,-,ed toadd or remo'etbe// commcntfromthe<\"",mlineofsourcecod.o,altofthe.dected .<;Outl."ecodclinesnlunce.Thisfc.,tnrei'ftttiv:,t<)dbypressingthe Ctrikeyplusthepl'Y"oo/'/,key.Byphys;oo/,lm""nthelow-level keyi:>oard key.whichgenerallycbangcsonforeignkeyboards. Forexample.oomyltali;).l\k,,)'boardlha\'etouseCtrl+iI.Thecontexl

lIlarcoCantil. Delphi Z007I1a.ndhook

1:The[)ctphi:m"7wr;·30

menuofll,eeililorshowstbeactuatshorlCU1kcyonlhesidcoflbe ToggleCon,m"ntonc"nit€m

• Click and Close. Youcun middlc·diok(ordkkthemousewheel) onalaboflbcC(lilortocloseit

• Clas. Navigation. You can mm-e from one metbod 10 lhe next one (orthepreviousoI>C)u.inglhekcl"oomb;n3tionC1rI+.>JI+OownAr row and Clrl .AII+Up Arrow_ etrl .. Ah.Uomc and Clrl.All.End bringroulothefitSlandlastmetbOO_ThisiscaliedClMSNa,;go· tion_Youc:onalsores1.rictmo\"ingll"ithinlhec"ITcnt,L;ssby activatingthnClassLock,pressClrl+Q""dthcIIL(koopingClrl PI'CSS<.-d). (I.ltJvetos.lyl cion't find this fe"''''e I'"niculorlyuseful, comparecitothcdnssicn"vigation"ithClr1+Sltift+Arl'Owtoj"mp b"ckandforthfroonthedefinitiontothcdcda"'1ionofamethod)

The Vel Form Designer

ilssoonasYO"I)I"ccane"'cimlrnlontheVCLfont\d",,i~ner(orthefrnme designe,),you'lIimmeiliale1yseesomelhingnew.ThecorncrsofthcconlroI andlbe=lralportionofeacbsideha" .. asmaUligblblU<':circie.These marktheresi...,area&oftberontrol:mO\iogtbemouseo,,,,tbem},,ucao rcsizeit (like in thep:tS1).

Now uyou pbr:ea second ronlrnl in the (onn.}"ul1 beal>letoseea nlOTl' usefulne,,"featurc,"DesignGuideline:;;'.Thisisavisu.l.idloproperly aligningronlrolson.foron:

M .. "",Cantii,Oelphi 2007 Hnndbook

"ThcOclphi"o07tI>E-31

Anothe,newfenlurl)i!;the"Fom, POSilionerinlhcoonomrighl oomerof lbeciesignerstlrf."",

Thcreyoucan<ec,ins,,,"Il,thep(JI;itionoflhcformonlhcscrecn, which is ,,,,clul ifth"forrnuscs~b$ol"tel>DSitioning, Youcm, "bouSClheFonn Posi tionertonlodif}·theTopilndLeftpro(>Crtiesoflheform'''ually.ThislOO\ rnnonl}'oousedwhcn}'otl uselbedef.mitembedded form designer. A \ittle lrno"1,fcatureisthat}'otle"nclicktheFonnPosilioncrlogct(lemJXlrarily) ahigger,-iewaodposilion lhefonn more precisely.

Text Baseline for Components Developers

Working "ilh the Design Guicieiincsfortheooruersoftheco"troisisquit e oLvious.BulhowciO(!Slhedesigncrknowsaooutlhclextbnse\ineforocon. trol?OfOQm"",;td_n":YQ"noed'opro"ide"TcOmpon"ntG"idelin~s dass.ndregistcritwill,ll,eRegisterComponentGuidelinesfunotion You""n~ndmoredetaiisinlbeDesignEdjtorsandVCLEdit01'Sunitsoftbe ToolsAP1VCLSOUI<:t!!rodefolder. Tbereisagli!aseline,,,,lucintheTDesi!loerGuideTypecoumeration,bul itisnotreallyrefe ..... ncedintbecode.wbilelbe.las:sml~hod TControlGuidelines.GetTextSaselinesetrnslop",,;cic.dernultirnplement.tion.ltloo\:slikeyouranfullycustomitelhebeha,ior,butha,ing " r""d)'·lo·\I""e'"mp\e .... o\lidntakelhiseasier.~

'4 1""'"',I""'""'t>.>,~""'«IO>deG<arlo>rmoreinlor"'."ion. ..

MaI'eoCanlil,l)r:ipbi:l.o07Handbook

1:Th"J)eJph;"OO7IDE_3"

Searching in the Tool Palette

Wbat is nice is th.1 you """ ..,Iect a new romjl<Jn~nt ~nd add it 10 tbe cur rent (orrn (or<reolea new unit orform)witbout ha"ingtousetbe mouse bUlaelh'3tingtbeTooIPaJettebypressingCtrl+Alt+Pandlypetberompo· neotitelnname,e>'entunllymc\-eO">rit";lblb"arTOwkeys.andpressthe Enterk"ytoselectiI.Wbil"inDelphi~005"nd20<l6Ihesek<:t;on"'"sfor tneinitialportionoflhete:<!(";thout_""nsidcringlhcinili"I"Tl,the.dec_ tionisnow"gainstnnyoecLlrrel\ceo(thetyp"dtc.t\\"ithillthc~omponcntor iten,nome_ Forex"mple.ifyo"lype-b"llon·yo"g~t,

iJ-~.- Co'

·

· -

-

.

·

Making Help Insight Work

i\n<>therreccnlf""tureoflh"edilorisHell'ln~ighl.'J"hissho,,"sa""mm"ry hclp window $ you move Ihe mouse over a symbol or sclect .n entr)" in lh~ <:od~romplction"fndo"_lftbcreisnoinform"tion"",ilable(orthesymbol, theprogrnmsho,"",lSUmtn.1'),oflbeS}"ITlooldctinition(wbereitisdefined,

I\tnrco CantU,Delphi 2.U07Handhook

"n",I)elphi2oo7I1)E-33

ilStypeil.'le1f.tbemetbodpa.rarnetersandreturn,.,llue,.ndsoonj,likethe follO"ingpararneterlessrnelbod

1"he tlelplt\sight,,;udow;';asrnall,·ersionoflnlcrnet Explorcr. Its out put d"l><lntL;ontbeHelpInsight.xsl)(S!.trnnsforrnalionfileuscdtoturntbe eoreXM!..dataintoproperHTMLand theHelpInsight.css file used to deterrnine·theeolor•ndfonlSoftbedispI3y.Bothfil<!!larestoredintbe ObjlleposfolderofDelpbi(againbydefaul!CodeGcar\RAD SlUrlio\5.o\OhjRcposj.Jfj·ouwanttotustomi>.etheuserinterfureofHelp lnsight,}.:>ucao<hangetb"""iwofill'S.

Generate XML Documentation

M8ITUC"nh·"Dcll,hil!o07Handbook

"Thcl)clphi~007IDE'34

<procedure name~"ButtonKlick." visibility:"published"> <p~rameters>

<parameter nameevsender" type_"TObject"/> </parameters>

</procedure>

<pr?c~dure na",e~"customMethod </me~b~~~;litY""PUbllC"/> </dass>

<variable na..e_"fOrlll" type~"Tf"r .. l"/> </namespace>

No"· )"ou can add custom comments to the XML Do<-umentalion by u<in~ the-tripleslash·synI3~·lIrorlhemulliline\"Crsions'·lt"and·[·!·.FOt ex'mplc.}"ou~.1n"'r;IC

IPUbliC

/// This is i1 cllsrommetilod, ofcouNe procedureCust~cthod;

TheinforJll"tionis~ddedtotheXMLoutput.asfoJlo,,",,·

I <procedure name.··custOlTW>lethod" visibility.··public"> <devnotes>

This isacustc .. metlwd. of course

</devnotes>

</procedure>

No"",ifl'oupro\idcnsl1111nlaryse<tioo"ilhinlheoommcnt.lbls,,iUsho"" ""in lbe Help Insight window·

I P?:{:;~~~~~~~.:!e:~o~: custom method, of courw/!w_i1rp

TheHe1"lnsigbtforthemethodnowberomes:

M3n:oCanru.Delphi:ZOO7I1andlwwlk

,,'I1,eD<:l]lhi20<>7IDI>-35

If )'OU ~eI into tbe babit of using this oom,neming S)lItax, )"01111 imme<lialely gel infonoatiOllaixmltbesymOOlsytlun::ferto,,·bilet),pinglneoode. Help lnsignt is. in r.,ct.aisolriggcredhytbeCodeComplction"indo",

To heip Wilh thisS)'Il1ax, you 03.n \)encfit fn)musingaouslomCodeTemplate,liketheonedestribedintheS<'Clion'"TemploteforHelplnsight Comm""ts-ofChaptcr~ NOIicelnat)"Oudon'tneedIOreC<>mpiletheprogramtobeahleloseetbe oomments in Ihe designer. as Ibe)' imme<lialclyshow upassoonas)'ou I)'pe Ibem.Asaready-to-useexample,wilhSCllcrnlrnslomHelplnsigbloom· ments,youcanreferlotheHelplnsightOcmoexamplc.

Other Features of the Delphi IDE

l'h""'''''''''"''y"lher"e"real"resinthel)dphilDEw",'hu,enti"nin~,Jx_sidetheeditorandthedes;gncr

Extended Search Results

TheMessagespane,generaUyplacedallbeOOttomofthelDE,displaysootb rompiler messages and search "",ults. E"en if simple 10 use, this ";mlow b8!;.o;evemlimptOvementso,-erpaslversionsofOclpbi.SinoeOclphi7)·ou h.""bccnabletodisplaysearcbresllltsinadiffercnt1absolhC)·donotintcrf<:n::withoompilerm"SSOgesaslheydidinlheprusl,Second,e\,"),lime you do a differenl search you c"n request that Oclpbishowthe"",ultsina d;ffcrentp"ge,,;otberesultsofp,evious"wrchop"r"lion~rem~inavailable.

MarcoC"m(.,D<:II,hi2007Uandbook

<:ThcDelph;:'.007IDE-36

File Browser View

The IDE in Delphi ~OQ7 has a new window, ealled File Browser, wbi.h hosts .mjniature,'ersionofWindo""Explorerthat~llOll'syoutoll'orkontbeme !'}'Stem"itbintbeIDE.

Anotherfeatmeisthatyoucanpro\ideafiltertoljmjtthefilesactualiydisplayedintheFjlcBro"'Ser.Use,,;ldeardsseparntedbysemi<ololl$,likein ,·.pas;'.dpr;*_dproj

Database Management Tools

Sin<cD"lphi~o05.lhcIOEimcgmles.O"laE,plorer";l\dowthalprovides ]jmjtedacocsstocialauascd,t.,nndme1adatalhro'lghlhedbr",presslibror}, In Delpbi2oosthjs\\,llslimitedlotbe.Nll·Bor]"ndDntaProviders, in DcIphj2oo6itofieredbOlh.whileDelphi2007supportsonlytheWjn3~ dat3baseac<;eSSlechnoiogy.dbExpr ....... TheinlegrateddatabasemanagcmentlooloflheDeiphjl!)Ealtow.j"uuto seetberonfiguredconnec1jons,testtbem.geta]istofthetablesforea<h

l~ TO<1oiseC\lSandTMoi>eSliNare",,,pluginloobforW;nd .. .,;F.,,,,lorer.p,,,,,idin& supponr"'CVS.o<!S"Imro""'.t~'opopuL.rop""·"'"I'Q!\""'''''ron'rol",,:sI'ms. Th<)'canbefoond a' htl~:!I"""..tonoisoc-'S.oryanda'hllp:llt<H1""",,,,""'igris.<q. respod;',,~.

MIlI"COCanhl.Delphi2<'>o7Hnndbook

1:ThcDelphi2007IDE-37

d"laJ,a'e,ancilhelistofficidsandindexcsofeachtoblc

(Limited) ALM Support in the IDE

The New Help System

ComparedtotheciassicversiousofDclphi.sinceDelt>hi~Q05theproduCl comes with a help file in the Microsoft Document E.pJorer format. Thcotd

MarooCanti'.lJelphi~o07Handt.o.)k

"Th"Delphi~OO7J1)E·l8

\\r,nHelpforrnalhashoondep'''''3IedbyMicroooftandisnotsupportedat all on Widows Vista

If)"Oua<eintc,esledinleamingaboulbowCode(;earcrml'''ilhebelpS}'S_ :~mandho""to,eportcrro~)"Oumighl,,"antloch""kCllrisllensen·.blOJ;.

Ihttp://chrisbensen.blogspot.com

Tn 1~1rticuia"yo" mighl "'nnl 10 search for" fO\lr·I~",11)Q.lt litled -[locum"nt3lionjHeiplnDelphi2007"

,8 If,.ou<bl·lcare.bool,a.,NEThelp,)·""can",,,,,,, .. il(l"OdllCi,,,,~,,,,,,,,,,,, ... ....rn. res"lts)"SUUest<dbyFomaOOaMadrug>;"hiobloc";hl'l':II""'m;",~onddelph;, bIogspot:,rom/20071O.jldtlph;·2007·Ior.~i03'-·~;~·rid-d.hlrnl

Mnr-co Cantio,Delphi 2007 Handbook

",Code Templates 3nd Refa<1oriog-39

2: Code Templates And Refactoring

Marco('aot\I,0eIphi,,-o07Handbook

'''Cod''Tcmpl"tcs""dR~f''clocing·40

Block Completion

Bcforeco\-ori'lj;CodeTemplatcs,itisimllOr~1nllocl""rUl'lheconflLsion "ilhanOlhc,relatedfcature,Bk>ckComp1ction.Whollhisdoes;'.utomJti. rnUY"'rilotheciosingclcmcntofm:myrodeblocks.

What is little known aboul llIockC"ml'ietio<l isthatit oot onl)' takes pi,," e whcfI}·oubillheEmerhy.hulalsowberelhe<t<rsurisatthctime.Fore •• ample,if}'ounccdtonddthccndsLltcmemoflhefoliowingblod'

lifmyTestth.n begin I

//do somerlring Don'tpressthcEnterk<!)'att"eenciofthelineoftbebeginstatcment (\\'h~re I'\'c place the V~rti<,,1 pille), which "'Quid result in Ihisc'Qcie

IH~i~15t then

//dosOIIIerhing

Rather. mo,." Ihe~"=rd0\\11 .fier lherode. where rcu "':Int the end 1000 inserted.andpre;sEnlerlhcre(seeagainlbeposilionoflbeverti",lpipc);

1"""""" begin

//do something I ,.,

Live Templates

WbilethcEDtcrkeytriggersBlockComplclion.lheSI~,ooa"dlabkeys""Ii· v~tcLiI'eTempIMcs.Fore""mJ'le,ify"ul"I'i!;ffollo",cdb)'asp.1ro!hc

M"r<:Ocantu,lJe!phi~(>07tl"ndbook

2:CodeTel111'IalCS,",l<IRcfaclorh'g"41

~"t"tcmen!wilioocomplctcd"iththcth.nl)O!1ion"nda"uggestional)O"! IlwtcstcxpressionthclLscrhastooomplctc:

-::".O.'"'"tr"~) .• u"O""''''''.""",, "",,,,"1

,::::·,:;=,:::c,.~1

~ T.create(self); '"

fi~~~~~;

end;

Templatesconfigured;nmanu"l moocare in;-oked ,,;tb !heTabkey,while automatictemplate«O'etriggercdby,heSp.l00key.Theycanalsobel;",ed,

M~rcoCantit,DeJpbi2oo7Haudboo~

~,CodcTempk'les3"dR"fnclo'~"Jl,-4"

pickoo. and edited io!he .. "wTemplatc\'ick·(use!bcl'iew I Templatcs mcnui!Cm!Oshowil):

Youoanalsoworkdire<tlyonCod"Tclnl'l.11esbyedilingtheirXMLS(lur<c e<>defil<o;"vailahleintheObjrepos\code_[emplates\cielphisubfolder of the RAD Studio instflilation folder. From the !DEyoll "IW <reate a noW Code Template \\;th lhc<;ommnnd File I New I Other I Olhur Files I Code Temploteorfrom \bcT~ml'lateView, using the New bulton.

M"'""oCantU,Oc!pbi:>o07Handb ...... k

2:CodeTemplatesandRefa<tOI"ing"4:.1

Customizing and Writing live Templates

Ma"""Cal1lii,OclphI20U7fiandh""k

~;C"dc'f"mpl"t"",,"dRefactorilg_44

I :~~!h\'~~Uage_""><![COilTA[]]>

<!code~ <!template> ~/codetemplate>

Firsl of "II ~()li"" th"tthe XML file declares itself asan UTF-8encoded fii~. hutbydelauit DclphigenernlcsanANSI 61einlheeditnr,soitisbctterlo .etuaUyS3"'l the file a. an UTF8 file_Tbisisporlicularlylnleifyou"'.ul In lype in aOOlnred letlersorspecialcharactcrs,>slfound om by pIIUing m)' n.meiolhcauthorfield!Tioemoslimp<lrlol1linfomlationisinlhenltribntesofthctemplateandcodetags.

The template Tag

;~~;:::n I.g of the XML lilo desoribing" li,'u template h>s the folio"ll1g a'-

• nalH!islhelemplate'sname,,,il'chyoutypeloinvokeil.Ofooursc lhi.iscompulsory,."dit isa1soquitcimportant to pi.k it wisely; "void keyworos 1I11lcss)-'OlL ,,,,,Uy",,nl to ha''e to type theex1,.codc ",'cl)'timc,avoidlong""meo;forcingyontotYP".I(,l..ndtrylo pickeasyloren,emoorones.

• invokeisauto.manual,ornMe,depcodillJl:"·he1heryouw,,ntlo pre;sSp.1ceorT"btoin,-ukethelemplatewhilel)"pi"~

• 5urrounddeterm;ne!;whetherthcte",plalec"nrn:,....das"Sn,ronndtcmpl.te.artlllud.selectedportionofcode.

• inplaceisaboole>n,.,.luedetermining"""P"nsiontemplale" (wh""" .. " that meons; nooeofthes~,~d1rd templotes ll5eS thi.~ ","

lnsidelhetempbtctaglberecanbesdiffercnt lypesoftags, There ""n I><u lextualdescription.anotb.rlext"ilh"nauthor.zcroormorescript l'W'tooousedloiD''OkeinlcmalopeIlllinllSoftheeditor,lhcrecani>eler-o ormorepcintlagoreferencingspecial positions in the code. mostlywbere thouserb"stot'Ompletcwhclll1singthetcl1lplatc,andfinnllYDcod.tag wilhtne3ctt",lcodeyouw3I\tlogenerale.

Thecode tag bas lh"'" ""r1butes: language.delimiter.~pdcon"e,,[. The language in Dclpbi2007willgenerallybe"Delphi-,asilOOte .... nincs fo'whlmt;'peoffilestbetemplotewillooacti''e.Tbedelimiterisgene ..... I.

MattO('antil.,Delpbi2007Handbook

~,CorleTc",plalcsa"dRcfactoring-45

SCl'iptsthmareLLSe<iinthepredefine<itemplatesa,e

• Invokecodecompletion

• populateCaseOwitbollcparamctel'

• rnvok.Classcompletion

• validateFOrTemplate

• DeclarevariableO"ithoneortwop.,rameter$

• RemOveTemplate

• GetClipboarcicontents(usedinatemplate"TittenbyAdam Markvvitz")

• varDeclToMsignment

21 Co,"plot.SQ"r,,,code",~ilabieat:http://,,,,rod''ll''''r.oo"''lt.m/oJ9tO

MarcoCantU,Delphi2\107Handbook

":Cod~Templat<:sandRefactoring'46

Asmootioncdcarlier,s<riptnodescanalsoappearunderthetemplatctag, inwhichctlsetheyapplytotheemirescript.Theycanha,'eoocoftneseat

Marco Cantit,Oelphi 2007 H,mdbook

,,,Code'J'empJat,,,,,,ndRcfa<10";ng-47

Custom Live Templates

MarcoCanlii,0eIph;2007Handhook

«:CodcTc"">lalesa,,dRcractorillg'48

InvokecodeCompletion;

~q=~:::

</text> <hint;.

dataset to lOQpthrough </hlnt>

</point>

<description>

Template to loop through. dauset while not eof <jdescript;01\>

<author>

leremyD.Mul1in

</author~

<Codelanguage .... Delphi ..

context~ .. methodbody .. delimiter~"1 "> be i~! [CDATA[whlle not ldataset l ,eof do

I*Ylendl

1·lldatasetl.Next;

end;

JJ>

</code~ </template>

A Live Template for Help Insight

AsweSllw in tbe )a$l ch~l)te', Hell' ltl,ight<au di"",tlydispl"y" comment youha''<lwrilteofo"hesymbolyoua,emovinglheonow;Cove,urtypingin ahiotwindo"'{Tbisisbe<:auseitworkstogctber,,ithCodcCompletion) 1be comment oee.;Is 10 be a special XMLDoc ""monen! and prmide a S\llMlar~XMLtag.So'omakeileasicr'o,,"ritetbiscode"''<lrand'''"et again,a LiveTemplale might rome h.ndy. How""n we invoke it?Otbers havepickedthexdocfake€lementtoexpand.solthoughl///wQuld!Je mQrC natur.l. How<.>vcr it ,!oesn't work,80 I settled for l/

Solbis ;smyl/ Li, ... T.mplate, mostly bo""""" from Fa...,1 Glo""aCki's XDoc:U ..... Templale"

I <t~~i~~!~~~~~~~~~~~:~~~~~:l~O~~'i ght</descri pti On>

MarcoOmtil,Delphi2<>07l1andbook

~:CodeTemplatesa[)dRefa<-1odl1g_49

I lefithetexttagemptyonpurp"se,hecausetbelastlhinkyouwamishac inglodelele.omeolhertOnlemheforeyou "'ritctI1eactu"1 oomment

Refactoring

maccoCanlu.,Delphi2007H~ndbook

,,-,CodeTe"'plate;;.n<iRcf"ctoring_so

l"rgc"",,,bcrofedili"~OI)"'"lion""1 ,,"ce,.'Llcb"sinthcmseoflile Re· nmner<!f"ctoring.

On lopofthisslructure. Delphi ~oo6addcdanumberofnc· ... refactorings. \\'hnlisimportanttonotireistbatmostortheoch·Delphi2006refactorin~ •relwtofTogctbers\ll'portandyouncedtoenahle1'ogether"slnooelingfor Iheprojetltousellleln.ThclDEhiilru;kyoutoenablemoddingifyoLllry touseoneofthese",f:octoringsandlhcmodclisnlncti,,,,yet."

Declare Refactoring

])elphi has IWn decl.re r~f"eloring nption~, Witb one keY>;1 roke o",~bin"tion (Clr!+Shift+V)youonndcolore.lo",.,]\".riable,wbilowithanOlner (Ctrl+Shift+D)you<andccloreafieldinlhcourreoltlass.Thepnrposeof thcselwOoperatioDSi5tolet}"Quaddn~"·storage"ithOlilchangingthecod· ingl'oi\ilion.50tbalyollcankeeptyp;ng.AUyouba''I!todoisfillin(iflhe dcliluI1.S3n'ootcorn'Cljnndacr:eptadi"logl>ox Bosidesle1tingyoul'roduoeeodefaslOr.lhishastbeadv"nl"gcofnolinlcr· rupting)"Uu,lhougntproces>byba,';nglojumparoundyou,somceeode YoudoO'tba .. elOm<)\'(ltothebeginofthelncthod.m.nu;.lIyaddingavar scctionifitisnotalreadythere(to3ddalocal,,,ri3ble)orjnmplotheciass Oflhcmethoo(lodcclareafield).Y""cansta}·focusedonthccodeyoua.-e

"tiling.

Boththcseh"ipers~uggest"lypefll,thc"c",,·ariahlcorfiddbeingded"re<l b.1B!:donlhCCtlrrenlc'On1mct.sYobasthcrighl.h,ndsideofa"""ignmeut Ihe typeoftheparameletofa methoo,or lhe expression «Inlex1. For =~m· plc.oodll""'aJiableisvcryhaodywbenwriliogaforl""I',3S}"Quoon·j h.''''10ffiaoU3llydccln.-ethel""p,,,ri.blc.A1lyouba''(llodoiltn)esomething like

I for ; :~ 0 to

gobacktothepositiolloflbcisymbol.""daCli'''lethedcda''''"ariable{by mearu;oflheshor1cut key,themainmenu,orilieoontexl menu). If you

Ma"",Cantii,DeIphi2oo7Handbook

2:C"d~Tcmfli;o(cs"ndJtefactoring·51

Extract to Resource String

Mar""Cantil,OcI(>lti~oo7Halldbook

2'CodeTc",plat""andR"r~ct"'';''J:-52

Thismeansth3tif)V\lh~,t:amethodliketbis

IProcedureTForml.ButtonlCliCk(sender:TObjeCt); strTest:string;

begin

SHTeSt ;~ 'Hello';

YOllcanmowtothestring(non.ootoselsotlbeentireSlring,j.e<rtmovcthe editorcursorwithinthcquot .. landaoti'·atetb~rclnotoringyau'llsee.dia_ logboxaod(by3<:<:eplingthedefaull>;}yoU"llgClthcfoU",,;ng:

I re~~~~~N;r~n~HellO';

p~~cedure TForml.eunonlclick(sender: TObject); strTest:string;

begin

strTest:mStrHello;

end;

The""me"ftheresour<'eSlringis,uggestedbylbesystemusingtbe3ctual lextoftbecolISlanlSlringandan-Slr"prefu",Tfthelextoftbeslringis '-cryIong,Delphi"iUpickuponlylbelirsrfewwor(\snndeapilalizethem forexample,if),",ulype(cnasinYeline)'

I St7,~S~'n:~ ;~~s ()~SC:'/:7ft~~n~ ~F!~o~hi~'7"n' 't mn

.fror calling l'.xlract Reso\\rreStringandacce[ltingthcdcf~llltS>it heromes:

1 ''''"''''''i"

StrTh1sHAverylong ~ 'This is.a very long string that

won"t even fit ina line' + 'ofcodeafterlrefactorlt';

Rename Refactoring

The Rename .. fuctoring (Crrl.~hift+E) is pmhablythc rnO!>! im(>Ortont refactoringinoTudedintheiOE-Renameisvcry(>Owerful.ndraol"'rkon different entitics: 'mi.bies. procedures, lypio-< (inciuding ciilsses),fid <Is, nndmClhOOs.Afloracoo»tingth~Renamedialogoo",ifyOlLkooplheVie", rcfc,"oeesoo.che<:kcd,you'llgetalistofchangesintheRcf~ctori"<lS"in·

'7Unfortunal.ly.thereisoo .... ,·'ocusrollli"'u,.Sltinj! ...... p .. rot.suet. .. 0l5ing ""'~"""'-Slr"."'hi<hrdti~btl.tor.

Ma~Cantu,Delphi~o07l1a"dhook

2:o>del"emplal<:5andRefac\onng"S;j

dow(bydefo"ita p",eciockcdtolhebotlOmoftheeditorj.\'otlta" '" "iew thcmanda«,cptorrejetltbe<hanges.

Marco Cantil, Dclphi 2007 Hand[tOok

:t: C.KleTell'l'l"tesalld Rcfnclori"g-S4

Extract Method

Anollocroffici"l,efacloring,possilllylhe.meproducing'1lOccoodcon},"", bebalflban.nyoflheolhelS,i<lbcExlrnctMethodrefaclo,ing

(Ctrl~Sb;fI +MJ_ The idea of Extmct Melbod is 10 tum a ""ipflCl of code inl0 a method. You might 1I"'U11to do tht. "'hen the metbod is ~cuing too 0001- plextou"derstando,be<auseyol1needtou<ethcsamooodcfl'omanQthcr onethod.What"sinlerestingintheExtrnclMe!hodrefactoringistho!v"ri_ ahles usOO in therodcsnippe1Sareautomal;e3!iy"..ssedasp.1rametelS to tbemeth<>d.(Noti<eyou3reoot."kedforthe,-isibilityofthenell"melhod, ostl,i~;.lin\·ariabl}'pri'""te:"henyouappl)"a" E.tr-dC1Mcthod ",F.!.ctoring. 3llyou(\on'tw"nltoohangetheinlcrfaccofthc<lass.) Intbiso:ase,tbedi:.logbO>::prmidesapm""'·oftbeeffectQftberefactoring.fnthisroolinn:.liondialogbox,yo~ruopro,;deaheuc;nameforthe newmc!h<>d,Forc<Unlple,youcanlurnlbcooreurlhefollo"ingforloop inlO ~ method'

e~~cedure TForlll.8uttoolClick(5ender: Tobject); i:lnteger;

be;~~s:r~~s:r::g~o do

begin outStr:;tntToStr(i):

L;>tBoxl.ltem5.Add(outStr)

en~~d:

In ihiscaselbe for loopcounter""riable i isp4SSOdosparu'"c'er1<>tiJ~ moth<>d,,,,biletheoiberJocalvariableisrnovedlolbenewnlethod,asitis nolonger,.'>e<linthcorigiualmdc.Thecomplctceffe<torthcrefactoringis the following oode":

IProc.edureTForlll.NUmberroString(i:lnteger); outStr:string;

begin

outStr :~ IntTo5tr(i); L1Stll<lxl.It.m~.Add(outStr); end:

M"",oCanliz,t)c1I'hi:.'.oo71Iandlmok

2,CodeTcmplatesandItcfaclOring.55

I procedure Tform1.ButtonlClickCSender: TObject);

be;i~l:t::e:; to 10 do

begin

tvumberTaString(i);

end;

end;

Theeffectisquitcnice,!"rtiollbrlyifyouC'onsidefthetimelhalmanlLally editinglhe,<>dein~sitn;hr\\'aywouldtake

~~~cedure i:lnteger;

n-:otal:lnteger;

beg1n

n~til :~~lOio 10 do begin

nToul :_nTotal + i, li,tBoxl.Items.Add(IntToStr(i)): end,

ListBod.Item'.Add (

IntToSu (nTotal));

end;

The Exlr"ct Methor) refa<iorillg"';liadrla ",fc,cnce paramolertalhe metbod",astheintern"\codeoftbeforloopaffect;anexternal''a,iablc:

IProcedureTForml.AddTOListCi:I.nteger; VarnTotal:Integer);

begin

nTotal :~ nTotal + I; li5tBo,l.Items.Add(IntTOStrC,)); end;

l\-IaIT<> Cantil,Delphi 2007 Handbook

~: CodeTelllpJ~tes,U\d Rcfaclori"g·s6

Tobject);

luthell""'edin~c()de,ifyoL1IL'" I rnc(nTotal.I)

Find Unit Refactoring

Marco Cantu, Irelphi:!.o07 Handb<>"k

2: CodeTemplatcsand Rcfactoring-57

Change Parameters

~I~ ~-.-~"- =_ ~

~ ~

=

=~~,

MarcoCantit,Delphi2oo7Handl>ook

:I.: CooeTemplatcsand lI.efac(or;ng-s8

Extract Interlace and Superclass

I tYi~est = interfa~e

pro~edure Test (x: Integer; suing):

end;

TForrn5 ~ cla"(TForrn, r res r) public

procedure Test (x: Integer; string);

end;

I ty~~aseForm - class abstract. (TFOrm) public

procedure TeSt (~: Integer; cons-ttitle:stringl;virtual;abstract;

Marc<>CantU,Dell,hi2007Jfandbook

2: CodcTcllll,latcs"ndRcfnctoring-S9

end:

TFormS_clasS(TBaseForm) public

procedure Test (x: Integer; consttitle: string); override; end;

Introduce Field, Introduce Variable, and Inline Variable

I g~~r~dure TFormS.Displaypos;t;on: shov.M~ssage (IntTOStr (Left + TOp));

end; i",,,i,,",,,,,,,,y,,,i,,",,

MarctJCan!iL,Delphi2007fi"Jldbook

:"CodcTcml'l"lesandltefactoring_60

affedll>eaclualsem"nlicsoflbepcotmm.inlnOSCCasIlSwherelncClCpression"'-.J .... lioncausessideeffects ImroduceFieldref:!cloringissimliarlolhclntrodU<eVariableooe.bulln thisrase)'Oucana!;oset lh~3rcessSP<'<'ificrofthefieldandwheretoadd thein;ti"li .. ~lionood,,_ Tblslslhecorresl)Ondin~dialogbo'(lJOticetheT i<on,indi"alingthlslspartofTogcthcrJ

l

More Together Refactorings

Thcreareothc'intcrestingrefactoringsinDclphi .• llbasedonTogether SUPl'ort.Thcfartioovcrthemmo,chriefi)·doeo1n·lmcan tb.tth~')·areless uscful.onlyth31tbeY3""simpiertodesrrihc:

• The two Pull Membcr-s Up and P .... h Me",be ... Ovwn ",faclori"", doexacil)"wb'liheirnrunesimply:1b"l'n,o'"metbodsorfieidsfmma ~Iasstoabasedassortoadori,-edclass.

• TbeSafeDeielerefactoringde!.enninesifanidenti6er(iikeafieldora mctbodjronhesafeiydcletedorifitslilln::ferencedd .. ewbereioihe oode.[nprncti""ihislsn·tmurhdiffcrentfmmr.ndingrefereoces,,;th thcret"ledDelphi~OO5command.

M"<c"Cu"tu.u.,Jphi~"o7Handhook

2: CodcTcm[}I"lcsa"clRefacIOI·ing-6,

Find References

Intheset<lndseetionoftbeScarchmenuandunderlheFind menu item of theoontcxlmonnofthccdilof.youcanseetl1recnewcommands·

• FindLocaIReferen<es.Fihr~lh"FindRcferen=searchtoth" currenlunilonl)'

M<Ir1:oC:ultil,DeI[}hi:>o07Handb-ook

2,C<KIeTe"'l,latcsandRefactoring-62

M:t .. ".,Canti',D<:1I'hi2oo7Hanrlbook

3;ProjectMan3gem~"tnndMSBuild-63

3: Project Management And MSBuild

Differeot from all pl'WiousversiollSof1'wbo pasca.l and Delpbi.theoew CodeGearIDEhasaoopeoaooflexibieprojectcompilationinsteadof3 hard-coded and doocd One

Compilations are performed using tbe MSBuild build en~ine. whicb is J13n ofthc.NET2.oRuntin>e(notofitsSDK)

Marcoc:ulIiI,lklphi2oD7liandbook

3:l'rojcctMaJutgcn1enlalldMSBuiJd-64

The .dproj File Format

Tbc new I'rojecl formnlmiollloobyDell'hi2007,whichi.diffcrent fr0111 "uy projectform't,,-,e(ibyDciphiinlhep,\:;I,w;eslile.dprojcxtensionandis .n XMLfiiebascdon Ihu MSBniid form.L When you opcn an e>t;sting project. Deiphi 2oo7ro,,,,crtsil (from a Dell'hi Sf6/7Proje<t ora Delphi 2oosf2006one)tolhencwfo,,".landsavestheronwnedlilew;ththe IlC",e>;IensioQ.Theolderproject file",rnainsa''Ilibblc. in mse)'auwant 10 reopeolheprQjectwilhanaldc,,-er<ionofDelpbi. Thefollo";ngisaDe>t"mp\ep~configu"'lionfileror.ba",.bonesnpplication.I'vemarked(inbold)someQftbespecilicsettingsoflbeprng"'",. lil<ethemainsour<:e,configumlion,lberompiler.titcnt"i""olions.and(towa,d.<tbcend)therefCri::ncctoti1eMSBuHdoonfigu,"lionfilelhall"'noml. theadu,lol"'rnlians""dlilallhcDeiphiselllpinSl"llsiulhcMSlluildcon figuration folder:

";:i:;:

"http://sche .. as ... icrosoft.comjdeveloper/ ... build/2003"~ <propertj'{iroup~

<projectGuid~

{S0867blb_c047_4S4d_Sea4"blb33870b06cj </ProjectGuid> <MainSource>Font.Test.dpr</Mainsource~ «onfigurationCondition="'S(Configuration)'=

Debu9 </Conflguration>

<platformCondition_" 'S(platforml' ..

AnyCPu

<!Plnform> <OC(_occcompiler~DCC324DC(_oc((ompiler~

~~~~:~~~~~~heckOUtPuttlame~

</DCC._llependencycheckoutputtlame~ <!Propcrtj'{iroup>

<p~oPertr.;~~~P

</propertj'{iroup~

Mar<:OCantii,Delphi:l.007B~ndbook

:1:Proj""lr.1anagcmc!llandMSlluild-6S

MarcoC>lnti',Dciph;2007Handbook

3: I'roj.,.,l Managemenl and MSlIu;ld· 66

<ItemGroup>

<oelp~icompile l~clude~""Font_sTest,dpr"> <MalnSource>MalnSource<!MalnSourcb </oelphicompile>

-occeere-ence Include~"FontSTestFor",.pas"> <Form>Forml</Form>

<joccReference>

<!ItemGroup>

<I:~~~~ct~

"~(MSBUildBi npath)\Borlaod.oelpni, Targets" /> <jProject> Projectgn>upfiles3realsoaulornaticallvmodifled,anduselheoewexteo· sioo.groupproj.Thcproj""lgroupconfigut3IionfilclislSlhe\,:lriollS proj""tsthatarep"rtofthcgroup,3Sinthep3SI,butalsopro\';desalislof MSBuildtargelsforcochprojccl

<C;:i:;;

"http,//s<:hemas.m;crosoft.co",/developer/msbuild/2003"" <propertyGroup>

<projenGuid>

{97S79Sf9-f6ff-422c-9c17-7839761S9S28} </projectGuid>

1,~~o:r;~~~o~~:

<Target Name=""Elevation">

<I-ISBuild projects="Elevation.dproj" Targets_"""/> </Target>

<Target Name_""Elevation:Clean""> <MS6uildprojects="Elevation.dproj Targets,,""Clean"j> <jTarget>

<Target Na"",~"el.vatioo;Make"~

<MS8uild projects_"Elevat;on.dproj" Targets_"Make""/> </Target>

<Target Naslem"auild"> <callTargetTargets_"Elevation""/> </Target>

<Target Narne_""cleao">

-<CallTargetTargetS_"Elevation:clean""/> ~/Target>

<T!~mT~:~:~""~:~~~~s_" El evati on: ",ake"" />

</Target> </project>

MarroCllntu.DeJphi20<>7l1andbook

3;ProjectManagemc"I~"dMSI:!"ild·67

In fact,aswc1Isee,oncoflhenel>-featuresassociatoo wilh Project ManagcrsattLcprojectgroups ic,-ei is the ability to handle Build Configurati ons and BnildTargets

The Build Process

Thebuildprocessin Dclphi 2oo7baschangedalolduelolbeadoptioDof theMSBuildengine.Youcannowseedetailedcompibtionoulpul,inc1ud· ing Ihe '-afious command. being e"",nted (and the compilation lime)_ You c"nperforme:<actlythesnmebuildope,ationsintheIO£andfromtheeom mand line. You can "cle<m"tomroraryfiles.And,mostofall,you<an customizcthebulldl'rQCcssinC<J\mtlessways

Manual Builds

YoucanuseMSBuild.exelobuild DcIpbi projectsfromlhecommandline. us!ngexactlythesameeompilcrandlinkeTse!tingstMlyou'duseinan IDE-basedcompilation.Thi.i.quitedifferentfromthepast.,,·heDtheIDE tricdtokeepdifferemproject~les(dof,conOin')'11c.

IC:\Windows\ .. i,rcsoft.NET\Framework\v2.0.S07Z7 lfthisfolderisDotoDyoUrp.1th,)"OUmigbt""antto~dditbcfo,,,youtryto useMSBuildfr-omtherommandline. TcuseMSBuildyoumightb,,""toaddtbe.NETbina,iesfoldcrtolom ~th_ Therommand·linesyntax ofth. MSBuild utility is

I"Tm~m~!:~~~~~~:config"r"t;on name>]

Thefirslp"mmeteristhclargct.Thest"ndordtargctsare

• Build foro OclphiCoOlpile(tbisisthedefault,.,tl"e)

• RcbnildforaDclphiBuild

~larcoCantU.l)elphj 2007 Handbook

3: I'rojed Management a"d M$BuHd· 68

• Cleanloremo,,:filesprxxiucedb,'lhecompilalionptoteSS,includ inglcmporaryDCUfiles,butaisocxecutnblefiles.Thisop",nlionis alsoavailablc\"inlheshort,ulmenuofthc Oclphi ProjeclManagcr, but not lilrOllsh IhcProject menu

Compilation Output

Youconuselhe"Verbosilj'"fieldoftbem.inpageoflneEu,·ironmentOptionsdialog oo .. toselect tbel",."l of details you aregoingtosee. Theoptions range from Quiet 10 Di:wwstic, hul my suggeslion is 10 Irick Minimal or Nonna!. Fore.ample a simple compilation with Minimal ,.."bosil}·produced,single(long)linelikcthefolloll,ng(inwhichr\'eomittedyarious seriesoflhesearchfoldcrs)

Iproiect",c:\USerS\MarcO\ ... \prOieCtl.dProi" (Make target(s)): c:\programfiles\codegear\radstudio\S.O\bin\dcc32.exe -DOEBUG-no-config

c:\users\M"rco\ ... \projectl.dpr

A similarproj"'" eompilcd with Nonrutl "erbosityprodu<:e$somethiogaloog tbisline{again"ithplentyofomissions): 8uildstartedS/17/200710:23:31PM.

project "'c:\UserS\Marco\ ... \projectl.dproj" (Make target(s»: c:\programfil.s\cod.gear\radstudio\S.O\bin\dcc32.e.e -DDEBUG-no-config

BU~ ;dU~~~~~d~d~\' .. \projectl. dpr

OWarning(s) o Error(s)

Time Elapsed 00:00:00.20

Ma1"<:U Cantii,l)elphi 2007 Handbook

J: Project Mana&ementa.ndMSBuild_6<j

Build Events

YouoansetlbeseBuildE''eIltsusinglberorresIKmdingsectionoftbe Proje<tOptionsdialogbo.,inthetwocategories(prc-buitd,[KI&-build) Thcrcyoucanseeasumm"rl'oftbeevents,editthcm,o,addnewones Whcncreatingancwcv""t,lheIDEopcnsupa(iiniogbo.iike'

IE-. §~~~:

, .

==_g;:::J

Youcantypcinthcmiddie!,an~"ndseiectmacr'OStoin\'okefromtheboltomone_Tbe"C':1ncelon Build Erro, flag indicates yo" ,,'antthes\opthe buildprocessiflberommandreturnsanon-zeroe,ro,cOOc

II-larco Canlu, Delphi 2007 Handbook

J

3:l'rojet:t!ll'U1"~e,,,clltandMSUllild'70

Custom Targets

<projectxmlns_ ''http://schemas.m;crosoft.c:om/developer/msbu;ld!2003''>

-~ .

project_"5(MSBuildExtens;onspath)\MSBUildCommun;tyTask5\

MSauild.community.Tasks_Targets"/>

dtomGroup> <Defau1tEXc:lude <Defau1tExclude <DefaultE.clude <Default1':xclude

~DefaultExclude />

~DefaultE,clude />

<Dehult",clude

Ma= Canlu, Dclph; 2f)07 Handhook

3,Projc<:tManagcm.,mand~iSBuild-7'

<oefaultE.clude I~clude~"~~\*.dcu" /> <oefaul tE.clude Include_"~~\~ .pas·· /> d}efaulte~clude lnclude_""\'.dfm·· />

</ItemGroup>

<Item(;roup>

<zipFiles Include_"~'\' .'" E.clude~"@.(oefaultnc1ude)'·/> </ItemGroup>

<T~~~tf~l':::i~~~~FileS)" ZipFileHame""naFco.zip" /> </Target>

<jProject>

Thelileirnportslhee<tcmJi t"sksanddelinesnlargctt~lIcd·Zip-"ndpro'·idesazipopernlion.Nowaliweha'"elodoistohooklbis,lclinilionpiaood insidealiiecallcd zip.proj 10 tiJe ''"tllal Deiphi project. All you havet odo is to mam4,lIycdit thcproje""t conAguratio~ file(i~ thca,"mplc sarnpleproject.dproj)addingtotbcfirstfe»·iiQcsthcelcmenlsmnrke<l iQbold'

/<7"",1 version."1.0·· enmding_"utf_8"7>

<project ,,,,,lns,.·'http://schemas.nicrosoft.cDlll/developer/ IIISbUl1d/2001"

Initialnrgets."build;zip">

<lmportproject .. "zip.proj"/>

<PropertyGroup>

Build Configurations

DiUerenrlyfrornlhepast"ndlil<emostC++developmcntloois.youcaono"· definemultiplen"medbuildconligurntions. Bydd""it. Dciphi""",tes(a1- mootidentic.'i) Debugand Rqleru;ebuiids.butyau<IInaddyo",own <:Qnfogurntionbytypinginn "ew".me. Buildcollr.gurntionscttingsal1ow }"olllona'·emultipieoompiiorandHnkeroptions.diffcrentdepio)"TIlentfoldets.differentder,nes.andtnelike.ThebuildoonAgurnt;o"oomboappcars in thefoiio";ngproject options pages: Compiler,CompilcrMCSlages. Linker,aodDil"ectories/CoDditionais.

Marl:O Cmlil., DoIlpili "007 Handbook

:l:l'lX'jcclMa""gc""'"ln"dMSII"ild·?~

Onceyou'\,cdcfioo<iandscllwoornloreoonfigur:llions.}'OII<anpiddle oneJ'o"w"nllo'c .. inlhecurrenl~\liltintheProj""tM"nagcr.Youb""cto ";ghl click on thel'rojecl GrollpclC1Ilelllundsel\l<1 the Conflgllration n>"n" agerP1en"ilcm(.n"l!~rn"ti"cisIOllsetbesame"'el1uitem,n""iloblei" IhcProjeclsectionoftlll!llIainDlcnu)'

The Project Manager

Besiciethcm"DuitomsloSllpportlheseleclionofahuildconfigmalion. wbich is ,,~'W in Delphi 2007, the Project M"na);~r",1w ",o"Y Ul)d:!tesduti,,& tbemDSl rotetIl,,,rsion.o;ofDelphi. Fore<anlplc,you can now add toa p[ojectanynon_Delpbi file: Theywon'l bee<>mpiled,ofoo"ISe,hut lhey11 be readily"vaibbleforyoutoopenintheeditor.Fo'el<ample,ifJ'ouba,,,1Nl OJ" XML configumlion r.ics for your project. adding I.hem to the project itself wilimakeil"el)'l'aSyloopenlhcm.

Mnn;o Canru,i)cll,hi Z007 Handbook

:1: 1',"Ujm:1 Ma"u);cl11e"l and MSBuild-7:I

Anolherextcn.sionialhcnbilitytodrnganddropfilesandpr<.>ja1sfrom lI'indowsExl'iorerintOlheProjecIManager,ao<lingfilestotlicprojec!sor projectslolheprojecll>to"p_The]>fnje<IM"n~erhasal.so"tl"lI'multi-sc_ Icctfcaturo:lf}'ouselectmuiliplefiles)'OUrannowopenlhcmall,save thern.lI,nndrem' .... "thcmallfrnmthel'roj.d.

Using Old-Style Build Tools

In Delphi2oo5and Delrhi~o06 (but not inDclphi2007)"itb .. alsooo.n p"SlibleIQintogratccxleru"ltoolsi1l lheProje<1 Mnna.ger''';lhlilcT ""lsi BuildTooiscommand.Tbcmonlltoinvok •• BuildTool,infaC1 .• pvearsin Ibecontext meau Oflh~=pOndin& nodeoflbe Project M3na.geL If}"" addancntrytotbell.st,j·oullseeth.1t)'0"havetosperifyoneormnreencn· "ions(adcfnulleXl"n~;"nplllSOlh"re",eD"ion").Aflcrthen"mclbat \";11 apl'eafinlhcm"D\I,lused~.e.eforlbedef""llaxtension'lIld·.dl1 for ~:~;tber extensions and entered the fo!lo"i"~ ",",lue of the Comm.nd Lil>(:

I "cS~:~~~~~~G~~~~~go50ft.NIOT\5DK\Vl.l\Bin\PEverify.exe" This .dds a ne'" menu COIl}' for ""'-'l)' £XE or DLL o.llin~ such an ""1",,,.1 progrnmisooosideredpo.nofthebuildJlflX'!SS,andtheoutpuloflheulCT' nalontpulisret!irectet!inlbesta"dardcompikrmessage>pMe. Needl"'loSil}-.invokingPEVcrifj'mokcsse'\Seonlyfora.Nlrr"1[lIIagcJ e.~....,t>1bl~, bUlaslbC're",n'tacor""'PODdin'5"ncric~erir,c.'I;ol\loolfor WinJ2nntiveuecutables,lkepilbiscxaml'leinlhebookanyway

32\\'ilhl"""""'MSB";ldwpp:Jl1",-.ibble,,,"ppor!;"&Il"'n~I\·il\'ll\<odbuildloolsil\ Delphi.OO7 ...... !<td ... ,,"'-

]'.I"r~oC.llh). Oclphi ~oo7Uandh""k

:1:ProjceIM,,"agemcnI3nd~tS811ild·74

Mal"'lOmlil,l)ctphi2007Handbook

4:TheOcbugger'75

4: The Debugger

OneoftbeC<lnstMlfeaturesoftbeOelpbiIDEhasin''lIri,blyboenaJlO"..,r· f\llinteg"'ted""bu"er,soyou\..,seldomhadloreacb{OTafull-ned,,~ 5land-alonedebLtgger. The Delphl debugger MS be;)n "cry pow"rful s;nce '..,rsionlandhasrl!<ci,'oomanysignifioanlimpro\'cmcntso, .. ,lhc\,,-<tc<)up\OOfye.'TS,Somcofthcseimpro\"emenlsa",notth:<tobvious.soquiwa fcwcicye\opetl' h"voo'wlooked \hem. Thisis why I d(.'Ci<1e.-d 10 llL'YOle a chapt."-jLllilforthis\opic.,,lbeit"shortone Asmoslofyouprob.,bl),ba''''yearso[experienceusin&lheDelphidebug· ~er.rttInOlgoingloinlroduceLbelopi<ofdebuWnginDelpb;,aJlbougb Ihereare'-eryfewbooksaboutil.nditmigbtO"""rthmoredetailedro....,r·

About Breakpoints

Un\=youplanto.pendah\lge.mounloftimest~ppinglhrough)'ourpro· STarns, the most romonon way of using !hedebugger in Delphi is to <et ""me breakpoints in Iheappropriateareasofyollrsoun:ecodeand inspect thesta· 11l$aftbeprogramallhnl$l>"'i6<point.You""nuseW<lI~beslokeeptrnck

Mru-coC<tnru,Delphi2007Handbook

4:TheDelou!;t:cr-76

ortbHaluesofs(lIn~r~IC\'lmt""iables,lookatl<)C;l!""riablcs{ofthe<ur","t stack fmmel, 1~'C Ihe ny_hy hint, open the Inspect wiodo,,,, to cb""k the st"tu.sorcOn'[lIln~"IS"ndolhcrobjects.or"'tiv"tethel·:,"luatc/Modify wio<iow[oexecuICC'I),.,;,ssionsolldmodifylilel'Oluel<of""riables Ilre.,kpoints show ul' in Ih~g"Ucronlh"sideoflhcedi\orl\;lld"w. \\;ll1di[ferentco!orsdcpendin&whcthcrlbcyareenal>k..:lornoI.Yollcalllurnon a"doff.breokpointMlbecurrcntlineiotheedilorwitl,lheFskey,.nd(in Delphi2oo71alsocnableordisableane.cistingbrmkpointusiogShifl+FS. Ify""reaUy",,"tlowork";lhthea<h-ancedfealunsofbreakpointsyou ne.:deitberloopenthellrcokpointspanc,whichlistsallthebrcak-pointsin Ibe~ntireprogrnmindioatingad'."n<edf""tureslikestheJlllSScount,tbe .M\JS,anal~ionnlcondition.thegroupandmore;"ry(lu<an"5etheBreakpo;ntspropertywindnw,,(opcn;nguplhead""nt-ro~ction)toselthe "ariousad"anooti f~"lurClSofea"h indi'idual b",,,kpohH. AlotofbreakpoinHclat"dfcatul'CSha'"ebeen"ddodtothcdeb"ggeroY~r the}'caI1;,!ikethedefinitionofbreakpointslhatlo~m=g""orl<>gthe,esultof!he"'''lualionofancxpressi<lnioth~£"entspane_Th...,b'''''1l'''ints C:>Dbe-noll-breokin~".mcaningtheydoOO!bal!tbeprogra"';n!hedebuggerbut"oniY"""lelbeinfonnotioD)"()udcfinoo'nll,el"" ,\nothe'"otionlhath",akpointseanperformislOacti''lIlcothcrbreaJ;l"'ints.Yaucnnfrcclydefincbreakpoinlgronpsandenablealiofthe bre.,kpoiutsinthegrouprnan""lIy(forexnmpleusinglheshortcutmcnuof IhcBI'e.1kpoints";ndows)ornutomati<allywhc,,anolilerbreakpointl.< fired.

Al"'Dulit"thatnll"fth"""~=kpointscanha"":o""""",,ioted<ond;t;on.dIberanumbcrofpassesor"nexprcss;onlohe"""l"tll00.Finally.anolhcr r""tunl oot all Delphiprog",mmer;;areawareof.islhcabilityloscta Data Brca1l"'int,abrmkpointthatislli!;t:credoslbepl'O&rnmcb"n&essornedata in"&lohalvariable

New Stack Breakpoints

Wh"li"specir,eallyncw;n])elphi~o07isthe"Lililytosctbr",1kpoiDlSon theSWckor,tobcrnorcpr«isc.allbereturn po;nlofa~ivensta.ckfrarnc_lf )'<lulookinthcS\llck"rnoe"indo"',",bileDelphii,dcbuggin~"prog"'m, youoanseeagr;,phie.,lindic.,lor(ina-minigullerlsho,,;ngwbetherthe

III",""" CantU_Oelphi "007 l1andlx>ok

rbisism<lreorlossiikeusinglhoR'mUntilH.eIL1l'tL'C'IL"""""ls",,,oral timesinarow(but onlj'ifthorcarenootberbreakj)ointsinbetween).l find RunUntiiRem",s''''l)'handywhenyouaetidentaily"tcpinloalo'''-ievel j)roccdure,butastrndnginlotbel3ststatementofaprooodurnoficobumps youiotolow-b",lrod",lfindstaekbrea~l"'intsqujlcdfccli,..,tolctthe progrnm&'thacklowberelwanttoresumedcbuggin~.

Fly-by Evaluation

Anolber,-cr)"b"ndyfcaturethatwasaddedsomelinleagobutexpondedin C<lchfollowing\'e!Sion(p;n1icularlyino"lph;2oo6),islheloollipsthal sh"'" up as you movelhemoUSl!O\wa S)",bol in theeclitorwbi!e a program is balled.1'bis isgcnerallycaUed Debug Insight or Ry-By E\"3IlI3tion. Simplyaddab""'kpointto3prograrn, run il 10 Ihol lox31ion, ma,'e tite mouseo'''''lhevnrioussymbolsintheedirar(loeal''IlriablcinlheoUJ"rcnt sraokfr:ome,ioeal"o",potlc"rsofthe~oth..,form.globaiobj""tslike" form vuri"ble)'ndyou'liseenhi"r"iththcv"lue.Focobjccts,thchintsh",,"th""~riOllSfields""dthcir\',lu!!S,,,hiicin tho past it used to display only" (possiblylonj;) list ohnlu!!S"ith no due what they W0rc for. SinceDe1phi2006.lh"""hintscanbcelCpooded(tlickingonthe+signon the side) tOge! a list o(oo..,classe;;. witb tbe6eldseaohoftheminlroduccs, plus a list of1oeal objects"i!h tbeir,"3Ines. In Iheeasewberea local field of a based=isanobjccritself,lbis<anbefurtbe,e,rrended io rhesame way. Tbesameobjeor<iatana\igariono:apobilityisavailableinmosldebug"iews. iQoIuding"'Iltohesandinspcctors.

To this rich v;"wofd"L1, Ddphi ~007 adds to thelool tips "/ad'''fJ ""pobili ty,"aUed-tra"'I'"rcnt tool lips-. BykeepingtheCtrl k"l'presse<i ,,'i1ilethe tooltipis"isibicY(}LL<"n,,,,,hitverylightsothnly,-,uo",,remllhesource rod"bebindit,andn:!;torelbcstando,d.ituationbyrele,1l;ingtheOrlkey. Tbis is hand)'OO<auseon<;eyou\..,opened SC"ernl sub panes, if you closelne toolliploge!b:ocktolookingaliliesouT<:erodeyotl1Incedtospenciquile sometime to reopen those.o;ame ponesa:nd ooDIionethed3ta inspection

M""",Calllil,Delph;:zo<>7Handbook

Other Features

Mal"£oCanru,Del]>h;"UU7Handhook

5'R~",cnllhJdalcsl"lhenell>hiLa"guagc-79

5: Recent Updates To The Delphi Language

Mar<:<l Canlu, Dell>hi 2""7 Handbook

5' KcccntUp<!atestoth"o.,lj,hiLanguage-80

When Private Is Really Private

Diffe,,,nt fmm most (,the, DOP lauguage",dass"W)ss specific", (like private and protectedjin Ddl'hi Qnly ,eslrict "Ct'<)l;S logivendass mcmbersfromrodeoul.Si~elheunil in ,,'bi,b Iheclassisdeclarod. Inotbe. won:is,aD),globalfunctionorauymethodofaciassw.iltcnin tbesameunil, <anareessthepri\·atedataofanyclass;nthcsameunit.Too\"Cl'<'Omelbis difference aod at tl>cs"me time m~iatain compatibility "ith Ihe oem.ntics oferistiogrode,Delphi200sdidn'tchangethebeha"iorofpr;vateand protectedhutintrooueedtbenewst;;ct pr;vateandstrict protected specifiers.

A!lanexampleofthesynlalCanderrormessagesyou1IgCi.=theP,otect<'<lPri',,!edemoin!bisehapter'srode.Thedemob"""conpleoftlassesand rodeusingthem,andyouoanexperimeot"i!hit bychan&ingtbeaccess specifi=_Theb;lsednsscodoisth-efollo\\;ng(!ist<'<lhcrconlyloshowthe """<!syntax)

I tY~~ase ~ class

Marco OmtiJ., Oelphi 2007 H"ndbook

5,RecelltUpdale_,loU,el)elphilangnage-8,

Classes and Inheritance

Abstract Classes

Actualiyin_NETiti,illeg.,1 to create "n instuoceofanabstractcia""whit It eve,woyyouo!Jtainedit,wltileioDelphiforWin32youonlyget.warning

Sealed Classes and Final Methods

M3IT(}Canli., Dclphi 2007 Handhook

5: Recent Update_.tothet);,!phiLanguagc-l!~

I""

TDerivl_claS5sealed(TBase)

procedure A; OVHriM;

end;

ItY~riVl_claSS(TBa,e)

procedureA;override;f;nal;

end; Inhcritingfromthisclos..mldo,-crridingthoA-methodc""sesthetompilcr error, "Cannot uyerride a final mcthod:

Class Data

MatcoCantu,Delphi2007Handhook

S,Re<:cIllUpdaleslothcDelphil.anguage-83

Howdoyou dedareet;w;data? Simply by defining a now _lion ofthedass marked"iththeclass varkerwordcomhination

ItY~¥Data_class

"';;:;;'"

conrnoncount' Int.g.r;

public cla<sfunctionGetCOIIIIIOn:lnteger;

n.eclass varsectioninlm<i""""ablockofoneormored.daralions.You c.1nuse"varseclion("·hiobisancww"ytoU5Clhiskc)",,,,rdjlodeclare moreSland.1rdfield.<:

1"~m:;:,:l'"

~a~ommoncount: Integer; MoreObjectoata:string; public

class function GetCoomon: Integer;

Inaddilionlodecl1ringrl:lSSdata,),oucan.lsodcfineot;w;projlCrties,as we'liseein the..,.,.,nd nexl se<:lion. Beforewe look tod:lSS properties. in fact,wehaveloexploreanotherapporenilystrllllge fe.1tUrC, in!r<.><lucedfor Nh"1'oompatibilily.cl!lSllsta!ieme!hods.

Class Static Methods

C13SSstaticme!hodsha'~beenin!roducedforoom""libililylolheCLSin tbe.NETcompiler,asDelpbiprogrammersoouldalreadyuscclassmetbods IOe.<pre;s3''''Ysimiiarooncep1.Becausetherearenolkmbleimplementationdifferences,Borlanddccidedtohavetwo""""rntef ... turesintbeDelpbi for .NET language, .nd .Isom.de them work in tbe W;n3' compiler aswell {tbefull implemcni.tionhru;been included since D<:lphi 2007)

Here is a simple aamplc with some incorrect statements commented out. lakenfromtbeClassStalicdemo

Marco Canlil. Detphi 2007 Handbook

S:ReccntUp;:iatcslotl,eOelphiLllnguage-84

type

TIlas" ~ class private tmp:loteger; public

class procedure one,

class procedure TWO; static:

C1a~5 procedure TBase.One; begIn

//frrpr: Inst;Jncellll!lllber 't!llp'

(:~;;{~el?o~!~)~"

wnteln (self.claS5Name); end;

classprocedureTBase.Two; begin

writeln('twO');

//error: Undeclared identifier // .. rireln (self.LlasSName); ~;eln(ClaSSName);

end; Inl>othca",,"you<antaUthcseclassmothodsdircctlyorinvokethem !"rough ~n object:

I ~~~~~~~:ase.create;

base.TWo; Ho;;ngCLS/C#compatibilityil1.NETisccrtainlynpius,butyoumight wonderifitrn:lke<anysens<ltoba,-elhisfMlureforWin32.However,lbere are two interesting (""IUI-e. thai makeeL,ssstatic metbods useful in Delphi forWin3~.Th.firstisthaltheycanbeused!odefinc<k""propcrtj",,"sdescribedintheDextse<tion.Theseoond;slhaldassstalicmethodsarefuU) C·languagecompaliblc_OneofchereasonstheywereintroducedinC.,a IMgl1'gewitilnoglobalfunctions,islhaClh,,}'eaubeusedtodclineWin' dowsAPloallbackfunctions.ThcsameisuLo;o!ruefo,Delphi.Yoll"'"Y objedtbalsineeDelphisupportsglobalfunctionsandproredures.lhisfMture isfur from useful. How",""er. ifj"oulook.Forex"mple,alhowlhe "tWioControlclasshook.stilewindowprocedufCWi!hoglobalf\lIlc!ion!h,,!

Ma"",enu\u, [)cl]>hi 2007 Handbo"k

5: Recenl Updates to the Delphi Language-85

calls" owthod.wdl. .. havingC",ssst,ticfunclionsw(luldha\"cm"d cthe rode look mlLchclcaucr.

I:;;'·d"",

callback:TFNTimerproc; beg;~

nTlmer(Ount :~ 0;

callback ;~ TfNT;merproc(@TFormCalI6ack.T;mercallBack); SetT1mer(Handle,ITMERID,lOOO.callback);

end;

Marco Canlu, Dt:iphi Z007 Ha"dbook

S:R""'''IUpd3I''.'lothel)CII,biLnnltllage-86

Class Properties

Aslmenlionoo,theOlberreasonforusingdassslali<:melhodsisloimpl<,Il1cntd.,ssprol'erli"". Whm is a otoss Prol",rt}·? Likeaslandnrti prOllC"yil i.a symbolallaclled 10 read and wrile medlO'u.sms. Unliken standard propCrtyilrelale:o;lolbed3S$andmuSlbeimplcmenledusingeiloerclaS$"(i.'la orclassstalkmelilods.TheTBased=(again,fromlheChlS$Slatic",,"m· j,lejbastwodassProllCrliescicfilledinh,'OciiffcrcnIW'YS

type

TBaa:clas5 private

classvar fMyName:suing;

pubH(

<lass function GetMyName. string: static, class procedur. SetMyName (V.lue: suing):

class property MyNMe: string

read GetMyName write SetMyNamej c1asspropertyDirectName:string read fMyN~rne write fMyN.me;

Nested Types and Nested Constants

Dclphitmd;t;ollallynttO",;yolllodecl;lfollcwoI.%scsintheilltorfacese<·lion ofaunil,aU""ingothernnitsoftkepmgrnmtorefcrcncetheln,orintoc implemenL1Iionsection,wbcretheyarea"',=ibleonlyfronLnlrlbod>of othc,d~ oftbeS<lmcunit or from global routines implcnlcnLed in IhM unitafierthedossdofinilion. DelpbiW(l5"ddednnOlberpo$'$ibility,namelythededarntionofad ... (o, anyotherlype)I";tbinanotherctass.;\snnyotbc'lIlcmbcroftnecbss,lhe nestec!cl=.ndothe'ne>tec!typcscanhavea,estrictec!visibilily(say.pri_ 'llteorprote<1edj.ReJe,=te.<amplcsofncstedtYpe5indudec:numerntions used bythcsameda.'IS "nd support classes.

A rdatedSj-11taxatioIVsyolltodcfinenneo<tedconsIMt,aCOn"lanl ,·"I\lc~".odated"ithlbeciass(agaiousableOtllyinternall),ifpri,"lcodrornthc restoftbeprogramifpubtic].Asanc"amptc,considerlhefollowingdecta-

Man:oc..ntU,0e1llhi20<ryUnndbook

5:)U,<cJltU]>datc"1"lhcDdJ'hiJ .. "n~"agc-87

ralionofa"esteddass(extral1cdf",mlbeNesl<!<lCllssunitO(lheN<:5ted_ TypesdcUlO)

type

TOne r class

private someoata:rnteger;

public

II neStedConHanr const foo= 12; /lneHedtype type

TInside B class

public procedurelnsideHelloj private

Msg:string;

end;

public

procedure Hello; end;

~~~cedure TOOe.Hello; inS:TInside;

be9in

1ns:"TInside.(reate;

inS.lnside>lello; writelnC'consranris'+lntrostrCfoo»;

end;

C~~1~dureTOne.Tlnsid •. InsideHello; SINIleData'=ZZ;

"rHeIn (';ncemaicall?; end;

The nested dass",," I>cw;eddireetlywi!hin thecl:tSS(asdenlUl'~traled in lhelisl.iogloroutsidelhcdass(ifilisdeelaredintbepublk...,tion}.b"t "iththefullyqualifiednameTone.TInsiM.ThcjUlinomeoflbedassis \Ised"lsointbedcfinitionoflhemL~hC>dofthcn()Sledclass,in this case TOne.Tlnside.Thismethodofthcncstedda".h"s~,ll.oo_tothcd"t"nf thehostingci.ass,indudingitspril'81ed't.1.Tbeh05tingcl .... canha'·ea fieldoftbenesteddasstlloeimmedi"lelyafteryou-'..,declaredtheneslod dass(as)'l'>ueanseeintheoodeoftheNestodC1 .... derno). Howwouldyoubcncfitf1"tlmusinganustedciass;utltcDelphilauglLJgc? The ooncept is commOllly userl in JR'" te implcm~nt event hnudlc", and

MarcoCantll.Delphi2007Ha,,dhook

5: Rcccm Up,l'lcstolhcDcll>hlL,,"g11agc. 88

Exceptions and Constructors

Tbisalsolmplicslnatthepropcrsequenceforatry-finallyshollldl>e("s yuu'lluften_incodc):

I'~'j'" '~n".mCc"'" '"

// J1se rh~ obJect ...

finall~

AnobJect.Free;

end;

36 !..o'erinthis,hapterth,reis'p,'ct;'"t"".",p"'i"~'hkhllestedcl",,,oo",.i" h'nd.","" .. I_I'iu,pic,,,..,.;ngacusIDmileratQrfor.for,,inloop

MarcoCantil,Deil'hi2007Handhook

5,RcecntUpdat"'to!hcDclphiLm'6'uagc-89

Class Helpers

!fthisisnotclcar,audilproboblyisn'l,let'slookataoc>:amplc(takcnfrom th,'C!assHcI""rDemoprojectj:

type

TM¥object_class pr-ivate

value: Intsg~r; Text: string; public

procedure Incr.as.; end;

~b~n~ctHelp~r" class helper for TMyObject

Ma,,,<>CalltU,Delphi2007Handbook

5: RecenlUpdatcsloU,elJelphiLnn"uage-"o

I "o~~ocedure show; lbepre<:edingoodedocbresacl:tssandaILclperforlhisc!ass.Thisml'.1ns lhnt from"n objectoftyp" TMyObj~n, yOlI c.m ""lithe methodes) oflho dnssaswoll".eachoflhcmelhodsofthecl.ls>heil)(lr

I obj:_TMyObjeu.create;

g~l:~~~~;:- 'foo';

Tbebelperclassmelilodbccon'cspmloftheclassandcanuseselfjustlikc "nyotber"'~thodtorefertothecmT~nlobject (ofthecl"lSS il helps 00.:.,,,,,, ciassheil"'f''',,-,notinotnntiMed),'lSthis"odedenlonst,nte>

IP,ocedu,emy<lbjectHelper.ShOW;

begin

WriteLn(Text+"+IntTOStr(value)+'--'+ className+'--'+ToString);

end;

finall)",1I01;""lbatnbelperda.o;omethod<llnm-erridelheorigin.lme!bod. l"thocOOel'veadded"showmethodbolhtotbcciUS$"ndtothohel)lCr class..butonlythebel)lCrelassmethodgctscalled1 Or«lmre,itm"k,,'"C.ylinlesensetodecL,rnaciassnndanc<lensionlothe ."",ec\ussu"ingtheciasshdl)(lrSl'nta,;nthes.,meunitorevenintnes,,1l'" program. What can he interesting, howm'er, is theabiht}· to extend "class defined in an me11l313$$en,bll'(and possibly",..,., "Til1enin"nOlherlan' gungel_Boriandilselfuscdelasshelpershcal'ilyinDelphi"sRTLtoexlend sl~nda,d _NETdasses~nd integrate with .NEf RTLSlIPllOrt.

M ",,,11,,,,,,, ,n ('hap'''''9.;n IJelt,h;~oo7CodeGeac'''''''cbsshelper.;loadd fC;)lIlIfSIQlheTCuStOlnFormciass,botin Ihiscaselhe"""",nwnslo"",;d ch,"ginglheillterfateoftheorigiMidasstomak"then~wunitbin.ry«l'n_ p111ible..-ilhlbeDelphi2006''Crsion.

ACl'Ording to Delphi's R&D t""n> mom!",,", them.1in rule is thatcl= hclpe",.houldbeusClI to bind thccorecl.soosofthelibrarytotlawplat· formswhilcmaintainillJ;cornplllibilit}'withexisting<:Ode_C1assheipers .houldnotl:tcused"~"g~nerallanguagecollS1n.tctrorde\·e1opiDgapp1ic3- tionsoroon'llOnenIS.Ho"",·cr,ltotonlytncRTLlibrari"".butnlsoth" higher-level ECO framework us",! class holpe .. extensively. Thereare.fewmorerul""tbal&pplyloel_helpers.Classhell'ermethods cnnh""ediff"rem"oocssspeeili~rs.canbeci"ssmethodsorvin"3Imethods (whicbcanbeo'ierriclden-tbecompiiernddsaointerfocebehindtbe

MalTIlC;mlil,o.,lphi20o7H""dlM>ok

5: Recenl Updates 10 Ihe OeIJ,hi lal'guage-Ql

seene:s),ando"nh."'Hlxtrnronstructors,dru;s,·.riabl es. propertie:s.orciass oper~tors.Tbconlyfi:.1t,,"'theybckisiDst"nredala. ,"""",,,,,,;,iI,I,'",",

A Class Helper for a List Box

Apm<1icaluseofdasshclpcrsisin p",,;dingerl]";l IllClhods for library classcs.Therea""nbcing)"Ondon't,.."nltochangeth ..... cl-.sscsdi,ectly (C'o·cnifYlJuhavetioesourrecOO.,loudon'I,,,,,Uy,..,,nttoerlitrn,,,VCL sou,ce:s)ocinheritfromtbcm(lli;thiswouldforeeyourcplarethecomponun~i"lheformsatde:sig"time).

As"n example. consider this simple case: )'OU w:mt ~ 8;mpl~ "'rt)'loget the textoflheclU,enlselectionofallstbo •. lnsteadofwrilinglhedassicrode

I ListBoxl.ltems [ListBox1.ltellllnde.j

)'OU candelioeaol;tss helpcras foilo",,"(takeo from the ListBo.Helper demo):

type

TListboxHelper .. c1asshelperforTList80. en~~nction rtemIndexvalue: string;

'~~~~ion TListbo~Helper.ItemInde.value· string:

Result :~ ";

if Iremlndex ~ .. 0 then

Re~ult , .. Items [ItemIndexl;

37 Yo""""writ.th.O>de"'so~'il"th.obssicif~,nen-~l.ut.I'",Oh'.,,"herl",,n t"in&,h<initial."it.n"<oo'tOlheRe;ult:

ifnornInde,;,_Qth.n

@l~!:~~: :: ~t~. [mmInde,)

Ilend,~p",r.r ... 'i",u,,;";'iali>od""k''3l_i"':todi"8'''''1\'ari.bIes.n<l''''''I'', ~':"~~OOI"rinIY"""'ired.becau>er.ilint'Odo",,'II;""''''''''''inhan;l-

r.llU"<Xl Cantu, Dc:lphi 200; Handbook

5: RccclltUp1l3IestotheDelphiL"ngu~ge·9~

The for .. in Loop

!I1~rooCanlii, Oclphi2007H~"dbook

5:R"centUl'datestothcDcll'hil~"''''lmg"·93

I """;cj,,,"""",,W,

be~~~rTI :~ aList.GHEnumuator;

vmi1eenum,MOveNextdo Listboxl,ltemS,Add(TObject(enum,current),(lassName);

I beO~~: TObject;

~or ,obj in aList do

LlStboxl.Items.Add(Obj.TOString);

Youcanalsouseenu",e~,ltorsinm3nyo!n"r"'"1SeS.indudingpredefined <k1!a types like strings and sets. He,eisonexompleb>S<.'<ionsll'ings·

Ibei~2~::;;o world';

forcMinsdo

Listbod_Hems.Add(ch);

IfyousticktolheWio3"OOmpiier,lbcfor .inlooptallbeusedtoncces' totneelomentsofthefoliowingd"tastructu,ClS:

• Charactersinasl,ing(secpreviou.codej

• Acti,'~ values in" .ot (Sf>!) !be ForlnWin3~ demo for an ",ample}

• lIemsinastatic{}tdrtlarnkarray,incl"di~glwo.din1"nsio"alal'ra)'5

• Objettsrefereneedbyciassesw;tbGetEnUmeratorsupport

MarcoCamii,Dclphi2007Handbook

5: R""cnl Updalcs 10 Ihc Delphi LlUlguagc-94

compone<11s.So,fol"cxampic, in " VCL forfll Y"" <all \\Til" the followi ng rocio (1Ig1lin from the ForinWin32 demo)

I "Co." •• "

begin

forCinSelfdo LiStBoKl.It~ms.Adct (C.Name):

type

TN~mberSRangeE"Um ~ class pnvate

npos:Integer, fRange:TNurnbersRange;

public con<tructorcreat.(aRange:TNumbersRange): function MoveNext: Boolean:

function Getcurrent: Integer:

property Curren~: Integer read GHCUrrent: end;

private

Fn5tart:lnteger:

FnEnd:J:nteger;

public funct;ooG.tEnumerator:TNumbersRangeEnum; procedureset_n€nd(constvalue:lnteger); procedureset_nStart(const.value:Integer);

MarcoCa,ltii,Dclph;"o07Handhook

5,I'("""ntUp<iatestothel)clphit-""'guage'95

readFnStartwriteset_nStart: propertynEnd:lnteger readFnEndwr;teset_nEnd:

ThcGetEnurneratormcthoocrcatcsanobje<:!<)f!i'CIlC.K,i!)lJelha!SIO,.es '!alllsinforUl'lionforilcrnlingol'crtbednta

fun~t;on TNumbersRange.GetEnUlOerator: TNumberSRangeEnum: begln

Result :~TNu~rSRangeEn"",.create (s~lf): end:

constructorTNumberSRange.TNumbersRangeEnum (~eate(aRange: TNumbers~ange):

be~ln

lnheritedCreate:

~~~~g~c:fR:~;~~~~tart - l;

end; Fin.lI)"lheenumerat(}Tm.ll,odspl'Olideae<:eSslothed.ln"ncim""""Cnl lolheuexl\"31ue

function TN .... bersR~nge.TNUl!lbersRangeEn"'".

GetCurrent:lnteger:

be~~~ult

end:

AfIeralltbis"w"'youcanno"'usetbefor .inlooptoitemtelhrougblhe vnlue!;ofthemogeobjcct·

aRange:TNumbersRange:

I: Integer,

be~~nge ;~ TNumbers~ange:create: 3Range.nsurt :.10: aRange.nEnd:.23;

for I in aaanqe do

List80o},ItMS.Add (mrroser (1»);

Macco('anhi.o.lphi2007Handhook

:;: R~-a:nl Updalcslnlh"lklphil.anguage-96

Inlining

1"liningObjoctl'nscalflmctionsandmctnodsis;,loh'-lm'cll:mgu"gefc.'iure iUlroduce<iin Dell'ili 2005J'.Gc"erally,h'ilen}","call" mClhod. tioc rom pi1- ergenerol""somccodUlolclyourprogrnmjUn1l'to" nc,,'oxecutiOll [>Oint Thisimpliessetl;ngUl'aSI~okframeaIlddoiDgaf",,"momoperations"nd mighltequite.dol\ellOrSOmaohineinstn'ctions.H"" ..... ..,r.tbemethod}"O" """"ute m.glll be '.\lry short. "",",ibly ""eo aD _cress metbod that simply So'lS orreturnssomepri, .. tefidd.[o.umacase,ilmnkesaiOloFso"""toooPl" Iheaclualoodelolhecal1locatioo,3\"oidinglbe.llIOxfrnmcSIllupaodeverythingel$e.Byrcmo,';ngthiso,mbead,),ollrprogr:lmwillruufasllt1". t~"tioularl)'\\'hen lhec"lll"kespla<eina lignlloope •• mtrothousandsof

For some very 5",~1I f"notions, lhe resulling rode mi~hl ",..,,, be. smaller. as IhecW€l'astedinpl10emighli>esmanlt1"lhanlhcoodcrequiredforlhc funclioo ""n. However,bolicelbal ifalonger~luotion is inlined and tbis funolion is<aUoo in mauydifferent place;iDyourpro;rnm.youmigbtexperienceoodebloal.whichisanunneoessaryincrroseinlhesizeoflbe execLltrJbJefile.

[n DelpbiyoU"3nru;klherompilerloinlin.~ mClhod(oraglobalfunctionj wilh lheinlinediroclh'c. plaoed after lne mclhod (or fnucl;on] ded"rolion, it isnot n='rytorcl",atlhi.,declaralion in the mothCJd definilion (thcmethCJdbody),Alwny!'kecpin mindlhatlheinline direcrh.., isoniy a hinttothel."",piler. which candec:idethallhcfunolion is nota good can<lidateforinliningandskipyourrequest ["ilhout,..arninSy<.Ju innny"'")' ) Tnerompilermigh131soinlinesome.butlOlnecessarilyall,oflbecallsof IbefuDctionaftC1"anal)""l.i,>&thecal!ingcodeanddepenrlingootbestall1Sof lbe'iINLINEdireetiveallbemIlingJoeaI'on.Thisdirecli, ... canaosume tbreediff.".""I,·alues(noli.:etbalthisfealureisindependeolfromtbeopti· mizationrompilcrs,,';lch)·

• Wilhdefa"II,,,h,e.{iINLINE ON},intiningis~n,lbledForfunctions ntarkedbylheinlinedirocti"c

381nlinin~ mb","(as.)p~""th<oth.,.h:u>d.hasboen.r..,u ... ofDelphi

andTlIttloP lfora!onslime.

M......,., Callni,Delplii 2007 Handbook

5: Recent Updatest" lhet)clphi L:",g,,~gc-'J7

• Wilh{SINLINE OFF)y"uransupprcssi"lin;ngin"pro~r.1""inn p<>rtionOhl'rogr,,",.orfor"srecificcall~ile.regnrdlC$Softhe l,rcsenreoflhcinlinedirceli,·cinthefu"rtionsl,.,i"'I:.,lIed

• lI'ilb{SINLIN[A(ffiI}tbecornpil"""illgenerollyinlinctheftmc_ Ilons)""markwiththedil'l!cti, .... pl ... automatir:lllyiuline''eJ}· short ~mrlio,,~.lI'alchouth,,"ausethisdi..,.,th'l).,,"c"userod~ blool

Tberean::manyfunctionsinthco"lpbiRTLIh.1tb3\'Cboonn13rkedasinlinera"didates_fore.nmple.lbel-la.~'nctionofthcMnlhun;tbas denniliol\slike

I fU~~!~~~a~~x~~~~~~t· B: lnuger): louger:

Tolestlhearlualcffcdofinlininglhisfunction,!','Cwnttcnlhefolloking loopillthelnliningTcslcxnmple:

ttt:TTi .... Test:

I,J:lnteger: b~gin

l:_O;

~~t: :" rr+eerese.create:

~or I :_ 0 to LOOpCount do J :~ I-Ia. (I, J):

memol.Lines,Add ('MJ)( '+ uLElapsed + '('+lntTOStr(J)+ 'j'):

final1y

end~~eAndNi 1 (ttt):

Inlhiswdc,lheTTi"'eTestci;lssisa>'Cf)'simplcrbsilbalu.seslbesysl"'" lime(lhrolLgiltheNowfuuction)lOgetlbeinili"ltimointhcronslm,lor"'1<.1 ""mpule how much lim~ haspassed in Ibe Elaps!d method(seelhesourcc oodeforrnDredi!lailll).Tbeforrnb3$I""buitnnsbolhmUirq;lbisrode.bul oneoflhcmhasinlin;ngdj;;abledJtlh~cal1sile(andaslighllydifferellll)"IpU!}. Wilh on~ hundred million inlcm~liolls, on "')-" ,oml)Ule, I gel the follolllngresulls:

l~fmH~l

\\"hichn\oonslhal;nli"ingmorelha"doubleslhe~,c<:ulionspred!Tbe snmcprng"'mdoesa$CCOndle$lwilhlhel~ngthfunClio".Origin.1l1)-"i" Delpbi~OO5lhiswmpilcr-magicfunctionrouldDOlbeinIiDed,wbilcsina!

Mnr<:OC .. nlu,o"JJ,hi""07Handhook

,,:R~'t:entUpdate.totheDelphiLanguage-98

MaceoC"nhl,Deiphi2oo7Handboak

tiollSam ne> ... , inlined ,,'hen thernarecin;ul:"unit rcre",nre«tbmugb lhci,implemenlationsettiollS).

Records on Steroids

A ",,,ord ,,~th metbods issomewbat simila,lo" class": tbe most signifitanl d;ffer<.'neeistb3trecordtypevariablesUSl!!oealmemo.y.tbcyarepaS'le<ias ""ramcterstofunctionsby~.,.luebydef"ult.Dndtl«:yh"vea-""pyby""'luebch3I'ioronassignments.Tbisrontrasts .. ith cLustype, .. riablestbat must i>e"llocatooontbe<i}"IlamicmcR>Oryhenl',arep'lsse<ibj·refemnce.and

h", ... a-cop}"bj·refereb""-heha'iotonassignments(tbus""pyingthe,,,f~r_ chcetothesameobjectinmemol)').A""nsequenceoftbisdifferent IIIcmorymanagementistbatrecordsL1ckinherilanceandpolymorpbisms.

type

TM~~ecord ~ record

pr~~~~eStrlng;

t"",:Integer; three: char;

~ublic

procedure Print; ccnstructorCreate(aString:5tring); procedurelnit(avalue·lnteger);

end;

M:t,"""o.nu·',[)elphi2oo7H"ndbook

5: KL,<el1tUpdatestotheDclphil.aJlgu~ge-lOO

Arerordc;malsob.,-earollSln,otor,butthererordronstrurtors,nustha,-e parnnoete""lfyoutry"ithCreateOyou1IgellheCITorrn=ge'Parnrnelerlessronstructorsn(ltnliowcdonrerordl}lleS·"WhyCodl-GearirnpOSed thi51imitationisfarfromdeartome,asyoU$lillhnl"eton,an,,"liyc.,lIth. C(Jnstn'ctor,ol'tionnIiYI':ISIlingparometer, 10 it {you 0;,,,,,o1 'L"<C tite con$tructorasalj"]lCcotl"orsim,.somcthingyoucaHusoll,eImplicit""d EXplic;topcrntorsfor.nsdisc"ssedlater).Hereis.1s,1ntplesnivpct

,."" ~,"""d, begin

.. yrec:wTJolyRecord.create('hel1o'); myrec.print;

Dclphistmallo"'"yo"todcfi"eeither.",rordornpocked",rord.Th~dif· fcreneeislrnditioruo.liytela!cdtuL6-bitor32-bitalignmentofthe, .. rious ficids.soihatabj1efollowedbyanintegermq;hlcnduplnkingup3:!bits ",·enifonly8areused.11,i$isbeca1l5eaccessingtbefoliu"ingintegen-allle onlhe32-hitbound:trymakestherodefu$l"rtoe:<ecule.

Records or Classes?

t}.'causetheroared ........ in'b~language,}"ou'"igh'wo"d"r.wbat'.'hcro· !ionaleforalsohavingrecords"i!hmethods?A:!idcfromthelackofmaoy nd,-aneedfeaturesofdasses.lhekerdiffur""""botwcenrecordsandclassei relateslo thewaylbeyuse memory. Thememozyneedcdforlhestorageoftbeficldsofaroronlromesfromlocalmemory:(i)lbeSl1ockifthererord"ariablci$alocal,·ariable,or(ii)th. nlemoT)'oftnchosling.mlastruolllreiflhereromisinside.",mherlj-pe(an army,anotherreroro,nclass ... ).Ontheotnerhand,,,cI,,,,.,,,riablemfield jgjusl'refercncctotbcmemo,yioeationwherethojnst""ocdmaishcld Tilis means cl"","," "ecda'peeificTI1€rnoryaliocalion. Liteirdatahlocksp",.

4,tnDelpbia.NEl".usiO;lhop,...,.,<L;nt_d"""tiooS;1lW_-..ff"""he ... ,;'I;.,n.",poniooO/,hoCtLaxie.

Marco Cantil. Dclphl "007 lIaJldbook

5: RL"",nIUpdaleslolhel)cll'hiLanguage.", ..

lidl"le in lhe memory man~"m"nt, ~nd Ihey musl c--em,.,lIy be reclaimed by thememory mnnager (including IbegmiJagecoliector in ,NEI1. Records jU:lrsitthereon lileirown and coot much lessto"lIo<ntc.managc,andfr "". AllotherreIL"'atl1diffcrelle,!isinthell'ayre<ordsarCWI)il-corp"ssc<iasl"'. rametm'S. In both ""l;l'S the default is 10 make a fllil wp)" of th~ memory blockrcprcsemingthe......:ord.OfOO\lrsc.)'ou<""uSIlv.rQt,onstreoonl paramcteJ'Stomodifylbisdefaullbebal<i<>r.Ontheronlral)'.>SSigningor passing an object isin'"3rlablynn opcration on IhercferenceslotheobjeclS' it"stbereFerellce thai isropied orpassed around. Togel.nideaoflhepcrformancedifFereneebel"""!n\LS;ngobjectsand rerords,laddedlolheRetonlsD<lmoeXilmplc,rnenlionooearlier,tII'ounilS tbatarcextremci}'similarbulu.sclhetwodiffcrcnt"pproaohes,·n,ebrule Fo,,-e rode I've written llsesntemporal)',"",orll n,ohj""1 insido "'Ulineslhnt arecAlled.1m;l\;onl;mes:

~~~ction computeoistancel: Double; ptl:TRecord""int; pt2:TRecord""int;

begin

ptl :~ TRecordpoint.t:reate (10. 20); pt2 :~ TRecordPOint.create (20. 40); Result:_ptl.oistance(pt2):

end;

~~~ction ComputeDistance, Double; ptl,Pt2'TclassPoint;

begin

pt1:_Tclasspoint.Create tro. 20), pt2:_TClassPOint.Create (20, 40); Result :~ ptl.Oistance(l't2);

end;

Tbegrealestdifl"ereneedependsoulhl'weigbloftheactuala!gorilbm{lhad loremol..,lhec:tllslorandomOlol'iginallyused",lhl:j-·slowedlhing:s dOh"lltoom"ob)andlheamounlofdataofthcstmotur .... 1bere:;ullofthe Reco";lsD,,,"oleslon my oomputcrgil'esa spee<.ioF498 m.forreoord< 8gn;'1S1~595Il1Sfo,clw;ses,T"edifferenceisl"rycl""r, lmdil;onalclassbasecic",lelakes5Iimcsmorc,Ailbougbthenlgorilhl\1l1'llSPUT}>osdYlI'ril lell 10 creale and deslroyloo manydataSlruclUrcs. it tell". iol aboul Ihe efficiencyofreronls.Asinothersimilarcases,inacolllt>utationallyinten. si''eopeI3lionlbedifFerenceis«:r\ainlyootieeable.wbiloform(l';l t>rogramsit "illbealmost unllOti"""ble.

Marroca,mL,lkll'hi2oo7Handbook

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master Your Semester with a Special Offer from Scribd & The New York Times

Cancel anytime.