Upload
others
View
21
Download
1
Embed Size (px)
Citation preview
MicrosoftVisualC++/MicrosoftFoundationClasses(MFC)FrequentlyAskedQuestions
MichaelPickens([email protected])
Version5.6
Lastupdated:7/01/98
ATTENTION!!!TheMFCFAQ
5.5isstillavailabletodownload.ItisformattedinfancyHTMLHelpsoyoucandownloaditandsearchitlocallyonyourmachine.Clickheretodownloadthefile(mfc_faq.exe1.34Mb-selfinstallingwithinstructions).
TheMFCFAQisgraciouslysponsoredbyStingraySoftware.StingraySoftwarewasfoundedtocreateandmarketMFCextensions.ItisourbeliefthatMFC/VC++developerswouldratheruseobject-orientedclasslibraries,insteadofbinary,blackbox,OLEcontrols(a.k.a.ActiveXcontrols).WearenowalmostthreeyearsoldandhaveseveralthousandcustomerswhoagreethatMFCextensionsareagreatsolutiontomanyWindowsdevelopmentproblems.
Hereisaquicklistofourproducts:
ObjectiveGrid-Thefirstandbyfarthemostfull-featured100%MFCgridcontrolonthemarket-clickheretocheckoutthehundredsofadvancedfeaturesthatthissuper-powerfultable/spreadsheetcontroloffers.
ObjectiveToolkit-Over50advancedGUIfeaturesfortheMFCdeveloper-bringyourapplicationsintothe90'sandblowawayyourcompetition.Includes:VisualStudiostyledockingwindows,incredibletoolbarcontrol,treecontrol,
mailto:[email protected]://ftp.stingray.com/pub/stingray/mfc_faqhttp://www.stingray.comhttp://www.stingray.com/ogmfc/default.asphttp://www.stingray.com/otmfc/default.asp
outlookcontrol,tabbedwindowsanddozensofothergreatfeatures.
ObjectiveToolkitPRO-AdvancedframeworksfortheseriousMFCdevelopersuchas:Model-View-Controller(designpatternthatenhancesdocument/view),layoutmanager,scriptingengineandmore!
ObjectiveChart-Theonly100%MFCchartingsystem!Tonsofcharttypesaresupported,andtheproductisalsoextremelyextensiblesoyoucanaddyourowncustomcharttypesinminutes!
ObjectiveDiagram-EverhavetouseGDIandMFC?ObjectiveDiagramhelpsyoucreateCViewsinminutesinsteadofmonths!
ObjectiveEdit-Anembeddablesourcecodehighlightingcontrol-hasacompleteVisualC++lookandfeel.
VisualCASE-TheonlymodelingtooldesignedfromthegroundupforVisualC++.
ObjectiveStudio-CombinestheStingrayMFCfamilyofproductsinconvenientpackagesforvariousdeveloperlevelsincluding:standard(forthebeginningMFCdeveloper),PRO(advanced-6month+-MFCdeveloper)andUniversal(multi-language[VB,VC,VJ]development).
http://www.stingray.com/otpmfc/default.asphttp://www.stingray.com/ocmfc/default.asphttp://www.stingray.com/odmfc/default.asphttp://www.stingray.com/oemfc/default.asphttp://www.stingray.com/vcase/default.asphttp://www.stingray.com/studio/default.asp
ClickheretogototheStingrayWEB!Freedemos,whitepapers,etc..
http://www.stingray.com
Instant-FAQ
ToautomaticallybenotifiedofnewMFCFAQreleases,weinviteyoutojointheInstant-FAQprogram.Tojoin,typeyoure-mailaddressintotheonlineformbelowandhitsubmit.Or,sendusanemailwiththesubject'SubscribeInstant-FAQ'[email protected]'lladdyouforfree.WeatMFCFAQheadquartersaimtoplease!!(Inotherwords,it'slikeafreeMFCFAQsubscription,thisisNOTamailinglistorlistserver.)
mailto:[email protected]
ShamelessPlug…Don'tbeoneofthefewMFC/VCdevelopersontheplanetwithoutacopyofMFCInternals!ThisistheONLYbookthatcoversthe"other"sideofMFC-howitisimplemented.EverhitanASSERTinMFC?Abug?EverhavetoworkaroundsomelimitationinMFC?MFCInternalsisforyou!ThebookcoversMFC4.0,butNOTHINGhaschangedsincethenintheareascovered,soitisstillaveryvalidreferenceforthoseofyouthatdon'twanttostopatthewrittendocumentation.http://www.amazon.comhasthebestpriceandwehavesomedetailsonthebookathttp://www.stingray.com/mfc_internalsorathttp://www.aw.com.
http://www.amazon.com/http://www.stingray.com/mfc_internalshttp://www.aw.com/
Buyacopy(or2orthree)today!!
Lookingforajob?StingraynowhasatonofjobopeningsandifyouareatthetopoftheMFC/ActiveXfoodchain-weneedyou!
Copyright
ThisdocumentiscompilationCopyright(c)1997byScotWingo.Itmaybefreelycopiedand/ordistributedinitsentiretyaslongasthiscopyrightnoticeisnotremoved.Itmaynotbesoldforprofitorincorporatedintocommercialproductswithouttheauthor'swrittenpermission.[Compilationcopyrightmeansthatyoucanfreelyuseindividualsectionsofthisdocument,butanysignificantcollectionofsectionsissubjecttothecopyright.Hey,Imaywanttoturnthisintoabookoramoviesomeday!]
ThisFAQisinnowayconnectedwithMicrosoft.Itcontainssomeanswerstofrequentlyaskedquestionsabouttheirproducts.Theauthorinnowayguaranteesthatanyoftheseanswersarecorrect.Thisisjustacollectionofinformationpostedtopublicon-lineforumstohelptheaverageMFCprogrammer.[Inotherwords,pleasedon'tsueme.]
http://www.stingsoft.com/aboutus/employment.asp
ReleaseNotesTheFAQhasbeencompletelyrevampedtobemoreusableintoday'sHTML-basedworld.TheMFC/VisualC++FAQhastonsofanswerstoquestionsyoumayencounter,bookreviews,VisualC++/MFCundocumentedsecrets,anunauthorizedhistoryofMFCandmuchmore!
We'llbeupdatingtheFAQbi-monthlyandfuturereleaseswillinclude:
SamplesthatdemonstratetheFAQs!HTMLHelpedition!CompleteVisualC++6.0coverage(whenitisreleased)-includingnewMFC/ATLlibraries.ManynewFAQs.
Manyofyoumaynotrealizeit,butwereceivealmostahundredemailsadayatMFCFAQheadquarters.MostoftheemailsareInstant-FAQ™submissions,butmanyofthemarequestionsaboutMFC.Unfortunately,wearenotabletoansweryourquestions,thiswouldtakefartoolonganditwouldonlybenefitoneperson-you.Instead,weurgeyoutopostyourquestiontoapublicforum,namelytheMFCnewsgroupsortheMFCmailinglistandwehaveevencreatedaMFCFAQnewsgroupthatweinviteyoutopostquestionsto.BysharingyourquestionandanswerwiththeMFCcommunity,manymorepeoplebenefitfromtheexperience.TheMFCFAQnewsgroupandavarietyofothersarediscussedinsection2.2.oftheMFCFAQ.
FYI,GeorgeShepherdandScotareregularcolumnistsfortheDr.DobbsJournal(TheUndocumentedCornerColumn)-http://www.ddj.comandtheMicrosoftSystemsJournal(TheVisualDeveloperColumn)-http://www.msj.comandalso(phew!)VisualC++Developer'sJournal-http://www.vcdj.comsocheckoutthenewShepherd/Wingomaterialmonthlyinthesedifferentmags.(TheStingrayscoopandmonthlyScot'sSoapboxathttp://www.stingray.comarealsoupdatedprettyfrequently.)
MichaelPickensandScotWingo-MFCFAQdudes
http://www.ddj.com/http://www.msj.com/http://www.vcdj.com/http://www.stingray.com/
mailto:[email protected]://www.stingray.com
mailto:[email protected]://www.stingray.com
What'sNewintheMFCFAQ?Ok-enoughramblingit'stimeforthemomentyouhaveallbeenwaitingfor-newMFCFAQmaterial!ThisversionofMFCFAQisonlybeingdistributedasanHTMLfilerighthereatthislocation.Ifyouarenotreadingthisathttp://www.stingray.com/mfc_faq,thenitisprobablyanoldversionsoyoushouldclickonthatlinkandgothesitetoseeifithasbeenupdated.IfyouwouldliketogetafreesubscriptiontotheMFCFAQ,whichissentviae-mailasHTMLHelp,thenclickhere.
OneofthecoolthingsabouttheMFCFAQisthatmanyoftheFAQshavebeenansweredbymembersoftheMFCteamorsomeonehereatStingraysoyoucanbeprettysuretheyaregoingtobehelpful.
Disclaimer:OneofthethingswedoatStingrayforproductideas,especiallyourObjectiveToolkitproduct,ismonitorthenewsgroupsandimplementthemostcommonlyaskedforfeaturesthatarenotinMFC.Forexample,howtoimplementdockingwindowssuchasthosefoundinVisualStudioiscommonlyasked.SotheanswertothisFAQisthatStingray'sObjectiveToolkitdoesthis,butitisnottrivialtodowithrawMFC.ItisnottheintentionthattheMFCFAQbeatotalproductplug,buttobehonestifthat'stheanswer,that'swhatisgoingtoendupinhere.Ifthisbothersyou,press"back"now.
Tofindoutwhat'snewinacurrentreleaseoftheMFCFAQlookforthesekeywordsthroughoutoursite:
NEW!!-Anentirelynew,freshFAQ!UPD!!-AnupdatedFAQ!
Or,typetheseintooursearchenginetoviewonlythenewestorupdatedFAQs.[NOTE:Theoldkeys(%and&)havebeenremovedbecausetheywerereservedinoursearchengine.]
IfyouhaveideasfornewsectionsoftheMFCFAQ(theActiveX/OLEsectionisadmittedlynotthatgreatrightnow),[email protected]
http://www.stingray.com/mfc_faqmailto:[email protected]
WanttolearnmoreaboutMFC/VC?TherearethreeresourcesIamcompelledtoplugthateveryMFC/VC++developershouldbeawareof.ThesearecoveredindetailinsectionTODO,butIwanttobringthemtoyourattentionheretoo.
1. TheMFCmailinglist-thiswassponsoredbytheworldfamousDavidElliott,butheburnedoutonmaintainingandmoderatingthelistandnowitissponsoredbyMicrosoftandmoderatedbyateamofmoderators.ThisisanEXCELLENTwaytolearnabouttheMFCFAQ.Detailsonjoiningareinsection2.2.2.
2. VisualC++Developer'sConference-Thisisaconference100%aboutVisualC++.IfyouarelikemeandaregettingburnedoutoneveryconferencesuddenlycoveringtheInternet,butyouwanttolearnmoreaboutOLE/MFC/ATL/VC/COM/ActiveXasfarasapplications/Windowsprogrammingisconcerned,thenVCDCisforyou.Section2.5hasdetailsorsurftohttp://www.vcdj.com.
3. VisualC++Developer'sJournal-BothanonlineandaprintedmagazineVC++/MFC-http://www.vcdj.com-excellentstuff.Theonlinemagazinecomesoutmonthly.Theprintedmagazineispublishedbi-monthlyinFebruary,April,June,August,OctoberandDecember.BothareFREE!!
Seealso:section13.5.5.
http://www.vcdj.com/http://www.vcdj.com/
1.MFCFAQInfoandCreditsTheMFCFAQmaintainerscanbecontactedatmfc_faq@stingray.com
Wewelcomeanycomments,criticismsorsuggestedadditionsfortheFAQ.
1.1.HowdoIgetthisFAQ?
1.2.What'sthegoaloftheFAQ?
1.3.Whyareyoudoingthis?
1.4.HowcanIcontribute!?!
1.5.HowisthisdifferentfromtheMSVCMFCFAQ?
1.6.WhatotherlanguagesistheFAQtranslatedto?1.6.1JapaneseversionofMFCFAQ
1.7.Credits
mailto:[email protected]
1.1.HowdoIgetthisFAQ?
Hey,thisisoneofthosechickenandeggquestions,ifyou'rereadingthisyoualreadyhavetheFAQ.Butseriously,theMFCFAQisputoutjustaboutmonthly,sochancesareyouarereadinganoldandstaleversion,insteadofthefreshandfancylatestversion.Ifyouwanttomakesureyouhavethelatestversion:
"Instant-FAQ"-Ifyou'dliketohaveacopyofanynewMFCFAQreleasesemailedrighttoyourfrontdoor,justclickhere...orsendusanemailviamfc_faq@stingray.comandwewilladdyoutothe'subscription'.Nocostoranything,justanotherFAQservice.
"WhywaitfortheannouncementsandthengogettheFAQyourself,use"Instant-FAQ"
"Instant-FAQchangedmylife!!!InolongerhavetowaitformonthsforthelatestFAQ.It'sjustwaitinginmyemailboxthesecondit'sreleased,nofussnomuss!ThanksInstant-FAQ"
-AnonymousInstant-FAQparticipant.
[AllrestrictionsapplyinstatesthatdonotallowInstant-FAQservice,pleaseseeyourlocalMFCFAQdealerfordetails.]
ThisFAQisonlyavailableontheWorldWideWebathttp://www.stingray.com/mfc_faq-ifyouarereadingitsomewhereelse(e.g.MSDN)itisprobablystale.
Sadly,IcannotemailtheFAQtoyoubecauseofmycurrentworkload.
IfyousendmeanemailaskingfortheFAQ,I'lljustputyouonInstant-FAQandyou'llgetthenextversionannouncementinstead.
AnannouncementofanewFAQreleaseispostedtotheUsenetnewsgroups:
comp.os.ms-windows.programmer.controlscomp.os.ms-windows.programmer.graphics
http://www.stingray.com/mfc_faq
comp.os.ms-windows.programmer.tools.mfccomp.os.ms-windows.programmer.misccomp.os.ms-windows.programmer.olecomp.os.ms-windows.programmer.toolscomp.os.ms-windows.programmer.win32comp.lang.c++
TheMicrosoftMFCnewsgroupswhichIcanneverremember.(news://news.microsoft.com/microsoft.public/visualc.mfcorsomethinglikethat)
There'salsoanannouncementontheMFCmailinglist.(SeeSection2.2.2.)
news://news.microsoft.com/microsoft.public/visualc.mfc
1.2.What'sthegoalofthisFAQ?
ThegoalofthisFAQistobeaclearinghouseforanswerstoMFCquestionscommonlyaskedonprimarilytheUsenetnewsgroupsandtheMFCList.Wetrynottoduplicatethegreatdocumentationoutthere,thetechnotes,MSDN,etc..HopefullyyouwilllooktherefirstandthenusethisFAQasyourlastresort.TheFAQwillbemuchmoreinterestingifyoucheckthoseresourcesfirst,thenwewon'thavetocover'thebasics'.
I'mtryingtoloadtheFAQupwithgoodphonenumbers,CODE-CODE-CODE!,URLsandemailaddressesofplacestocall.I'llbeputting800numbersfirst,andthentheUSnumbersecond.Internationalfolkshateitwhenthereareonly800numbers,soifyouwantaphonenumberintheFAQ,pleasesendboth.
1.3.Whyareyoudoingthis?
Ikeepseeingthesamepostsandthey'redrivingmeinsane!!!Butseriously,IstartedtheMFCFAQwhenIhadgobsoffreetimeandwastryingtogetreallytotallysubmergedinMFC.Ifigured,whatbetterwaytogetsubmerged,thantomanagetheFAQ.
1.4.HowcanIcontribute!?!
Goodquestion!YoucansendmeanemailwithyourfrequentlyaskedquestionandanswerandI'llstickitrightintheFAQ.It'sthateasy,We'llevenmakesureyougetcreditforthatentry.PleaseremembertotellmewhatsectionoftheFAQyouwouldlikeyourFAQaddedto.
Also,ifyousearchforthestring'%%TODO'thatindicatesthereissomeinformationIneedtofillinandwouldreallylikeyourhelpwith.
1.5.HowisthisdifferentfromtheMSVCMFCFAQ?
ThereisaMFCFAQthatcomeswithMSVC,thisFAQisdifferentbecause:
1. It'snotfromMicrosoft(soithasmoredirtandlessevangelism!)2. TheinformationhereisgleanedfromUsenetandCompuServe,wheretheir
informationisfromtechnicalsupport.HopefullytheUsenet/CompuServefolksaskbetterquestions(theyaredefinitelycheaper;->)
1.6.WhatotherlanguagesisthisFAQtranslatedto?
1.6.1.JapaneseversionofMFCFAQ
IamcoordinatingeffortswithMasahikoFunakitohaveaJapaneseversionoftheFAQ.HegetsallchangessothathecanmaintaintheJapaneseversion.Hecanbereachedviaemailat:'[email protected]'.
TheMFCFAQ-Jisnowavailable:http://www.st.rim.or.jp/~funa/mfc_faq.html
mailto:[email protected]://www.st.rim.or.jp/~funa/mfc_faq.html
1.7.Credits
IborrowedtheformatfromTomHaapanen'sWindowsProgrammersFAQ,soI'meternallyindebtedtohimforthat.TomalsoknewtheexactdatesofallMFCreleasespracticallydowntothesecond.
I'dalsoliketousethisspacetothanksomeofthefolksthatalwaystryandhelpoutpeopleontheUsenetgroups:
ChrisMarriott-HehasthehighestbandwidthofdarngoodanswersI'veeverseen.
MikeBlaszczak-AMicrosoftiethatreadsNetnewsandgivesgreatanswers!(Seesection2.4.2forinfoabouthisbook!)Ifanybodyknowshowtopronouncehisname,letmeknow..MikeisnowtheleadoftheMFCTeam.Ifyouseeaguypostandhesigns:
.BekiM-thatisMike.He'salittlebackwards,butgivesgoodanswers.AskhimabouthisRX7.
AndofcoursethankstoeveryoneintheMicrosoftMFC/MSVCgroupthatmadeMFCthephenomenonitistoday:ScottRandall,JimMcCarthy,DeanMcCrory,JohnElsbree,etc..,etc..
ThesefolkshavegivenmelotsofgreatfeedbackontheFAQandgetabigroundofapplause!
[email protected]@diku.dkVinnyMayfieldconvertedtheFAQovertoWordforme.
IndividualFAQcontributionsareusuallyneartheFAQ.
2.MFC/VC++ResourceGuideHopefullythisFAQiswhereyouwilllookwhenallelsefails.Thissectiondocumentswhatelseisoutthereandhowtogetyourpawsonit.FYI-Thissectionusedtobecalled"JuicyMFCInformation".
2.1.Microsoft2.1.1.VisualC++andVisualC++subscription2.1.2.MicrosoftDevelopersNetwork(MSDN)2.1.3.KnowledgeDatabases2.1.4.MicrosoftSoftwareLibrary
2.2.Internet
UPD!!2.2.1.WorldWideWebPages
2.2.2.Mailinglists2.2.3.UsenetNewsgroups2.2.4.OtherFAQsofinterest2.2.5.FTPsites2.2.6.TheMFCFAQFTPArchive!
2.3.CompuServe
2.4.PrintedMatter2.4.1.Magazinesandjournals2.4.2.BooksonMFC
UPD!!2.4.3.CoolMFCArticles
2.5.TradeShows
2.6.UsersGroups
2.7.TechnicalSupport
NEW!!2.8.MFC/VC++RelatedCompanies
2.1.Microsoft
MFCcomeswithMicrosoft'sVisualC++,Watcom'sC++,andSymantec'sC++compilers.
2.1.1.VisualC++andVisualC++subscription.
MicrosoftnolongersellssubscriptionstoVisualC++.However,youcangetupdatestoitthroughtheMSDNUniversalsubscription.SeeSection3forthedetailsofwhatMFCreleaseisthelatestandgreatest.Onlymajorversionsaresoldthroughoutlets,soifyouneedapointrelease,youneedtheUniversalSubscriptionthatisnowdonewithMSDN.
Pricesfluctuate,socontactoneofthecompilervendorsforinformation:
Microsoft(800)719-5577(206)936-8661http://www.microsoft.comWatcomandSymanteccarryMFCcompatibleVC++'sbutIthinkyouwouldbenearlyinsanetochooseoneoftheseoverVC++.TheytendtobebehindVC++infunctionalityandneverseemtohavethelatestMFC.
TherearealsotwoprogrammermailorderhousesthatcarryalloftheMFCsupportedcompilersincludingtheVisualC++subscription:
Programmer'sParadise-Mypersonalfavorite.(800)445-7899/(908)445-7899TheProgrammer'sShop(800)421-8006/(617)740-2510
2.1.2.MicrosoftDevelopersNetwork(MSDN)
AnothergreatinvestmentistheMicrosoftDevelopersNetwork(MSDN),whichisaquarterlysubscriptionsetofCD-ROMsthatcontainsalloftheinformationyoucanimagineabouttheMicrosoftdeveloperproducts,includingMFC.Therearetwolevels,levelonegetsyoutheCDsthathaveallthedevelopertoolinformation.Hey-theMFCFAQisevenontherenow.TheMSDNoptionschangealmostmonthlysoinsteadofdetailingthemhere,whydon'tyoujustsurfonovertohttp://www.microsoft.com/msdnandcheckoutwhattheyhavetosay.TheUniversalsubscriptiongivesyouthebiggestbangforthebuckbecauseit
http://www.microsoft.com/msdn
sendsouteverythingyoucouldeverwantinoneaffordablepackage.
IfyouareInternetchallenged,youcancontactMSDNat:
(800)759-5474(303)[email protected]
2.1.3.KnowledgeDatabases
Microsoftsupportcreatestheseknowledgedatabasesthatanswerfrequentlyaskedquestionsandsometimeshavesamplesandstuff.Youcangettheknowledgedatabasesfromftp.microsoft.com,CompuServe,andtheycomeontheMSDN(seesection2.1.2above)CD-ROMs.
There'satoolthatletsyouquicklysearchthese.WheneverI'vetriedtofindsomethinghere,IalwaysendupwithMFC1.0informationthat'snotveryuseful.Yourmileagemayvary.
http://www.microsoft.com/KB
IstheURLthatIuse,changetheproducttoVisualC++andpartyon!
2.1.4.MicrosoftSoftwareLibrary
Microsoftmaintainsagiantlibraryofsamples,tools,anddemoscalledtheMicrosoftSoftwareLibrary.Here'showtofinditonthevariouselectronicmedia:
CompuServe-GOMSLMicrosoftDownloadService(MSDL)Dial(206)936-6735toconnecttoMSDLInternet(anonymousFTP)ftp://ftp.microsoft.com.ChangetotheSOFTLIB\MSLFILESdirectory.
JohnElsbree,[email protected],programmer.misc,6/24/95
http://www.microsoft.com/KBftp://ftp.microsoft.com
2.2.Internet
Throwonsomesunglasses,putthetopdownandtakeacruiseonthatbigole'informationhighway.There'stonsofgreatMFCinformationatyourfingertips(sorrybillg),ifyouknowwheretolook…..
UPD!!2.2.1.WorldWideWebPages
HerearesomeURLswithMFC,orMFCrelatedinformation:
http://www.microsoft.com-Microsoft'sWWW.http://www.microsoft.com/visualc-VisualC++MotherShipforinformation-checkthisweeklyifyouwanttobereallyhip(oraBIGVC++NERDdependingonyourperspective).http://www.stingray.com/dev/dev.htm-ForMFCDeveloper'sONLY!!http://www.webcom.com/~sleslie/resources.html-GreatpagebyScottLeslieofVC++/MFCresourcesontheweb.http://www.stingray.com-MFCextensionscompany,StingraySoftwarehttp://www.visionx.com/mfcpro-TheMFCProfessional-asitethathassomeusefulMFCinformation,notupdatedveryfrequentlythough.http://www.vcdj.com-VisualC++Developer'sJournal.http://www.r2m.com/windev/MFC.html-MicrosoftFoundationClassesInternetResourceshttp://www.richardhaleshaw.com/-RichardHaleShaw'spagehttp://www.program.com/index.html-Program.Comhttp://www.kudonet.com/~ixfwin/winprog_faqs/winprog_faqs.html-InternetWisdom:WindowsProgramminghttp://www.aul.fiu.edu/tech/visualc.html-VisualC++ProgrammingPagehttp://walden.mo.net/~mikemac/progdir.shtml-TheProgrammer'sLinkhttp://www.grfn.org/~ypwong/ComputerProgramming.html-ComputerProgrammingResourceshttp://www.webcom.com/~sleslie/resources.html-MFC/Win32/VisualC++ResourcesontheWeb
Lotsofmagazinesareontheweb,seesection2.4.1forthoseURLs
2.2.2.Mailinglists
http://www.microsoft.com/http://www.microsoft.com/visualchttp://www.stingray.com/dev/dev.htmhttp://www.webcom.com/~sleslie/resources.htmlhttp://www.stingray.com/http://www.visionx.com/mfcprohttp://www.vcdj.com/http://www.r2m.com/windev/MFC.htmlhttp://www.richardhaleshaw.com/http://www.program.com/index.htmlhttp://www.kudonet.com/~ixfwin/winprog_faqs/winprog_faqs.htmlhttp://www.aul.fiu.edu/tech/visualc.htmlhttp://walden.mo.net/~mikemac/progdir.shtmlhttp://www.grfn.org/~ypwong/ComputerProgramming.htmlhttp://www.webcom.com/~sleslie/resources.html
TheMFCmailinglistwasoriginallystartedbyDavidElliottandnowithasbeenpickedupbynoneotherthanMicrosoft(BigBrotherislistening!).Butseriously,itisreallygreatthatMicrosoftdecidedtokeepthissourceofpeer-levelsupportalive.OhMFCmailinglist,whydoIloveyou?Letmecounttheways:
1. Verylownoise.2. SometimesMikeyellsatpeopleanditmakesmelaughuncontrollably.3. It'smoderatedsosomeoneelsehastodealwithallofthebounces,weirdos,
flames,spams,etc..4. It'sanadvancedgroup-thereareno:"WhatisCObject!?"kindofquestions
-oratleasttheyarefewandfarbetween.5. WanttolearnMFC?Spendtwoweeksreadingthisandseeifyoucan
answereveryquestion.Don'tstopuntilyoucan.YounowknowMFCbetterthanthetop2%ofprogrammers.
Interested?Instructionsonjoiningareat:
http://www.microsoft.com/workshop/essentials/mail.asp(youmayhavetohaveIEtoviewthis,don'tknow).
Thereisanicearchiveathttp://microsoft.ease.lsoft.com/archives/index.html
Ifyouwanttohavesomefun,askifyoushouldcallTerminateThread()!
2.2.3.UsenetNewsgroups
YoucangettoUsenetgroupsthroughtheInternet,orthroughmanyoftheon-lineservicesthesedays.Here'saquickrundownofnewsgroupsthathaveMFC-specificcontentorsimilarthingsofinterest:
comp.os.ms-windows.programmer.tools.mfc-AMFC-onlynewsgroup-andit'sagoodone.ThisisrelativelynewintheNetnewsUniverse,soyoumayhavetogetanadministratortoadditatyournewssite.It'savailableonMSN,AOLandCIS.comp.os.ms-windows.programmer.tools-ThisiswheremostoftheMFCstuffUSEDtohappen,nothingbutnoisenow.Youwanttocheckoutthe.mfcgroupfirst.comp.os.ms-windows.programmer.misc-Giveitashot,lotsofnoisehere,butusuallygoodnoise.
http://www.microsoft.com/workshop/essentials/mail.asphttp://microsoft.ease.lsoft.com/archives/index.html
comp.os.ms-windows.programmer.win32-Ilikethisgroup,doesn'tseemtoocrowded,peopleknowwhat'sgoingon,Iguessbecausethey'rereallyintowin32.comp.os.ms-windows.programmer.ole-AnoccasionalthreadaboutsomeoftheOLEclassespopsuphere.comp.lang.c++-ThisissupposetobeforC++languageissues,butpeoplearealwayspostingaboutMSVCandMFChere.Thisgroupisreallyfrustratingtoread,Irecommendstayingaway.There'sabouta100000:1noiseratioinhere.
MicrosofthasditchedtheirCompu$erveforums(Yeah!)andnowtheysponsor"peersupport"viaanewsserveratnews://msnews.microsoft.com.Pointyournewsreaderthereandthennavigatetothemicrosoft.public.vc.mfc.ThereisawholehierarchyunderVCyoumaywanttoexplore,butthisoneisthemostactiveandinterestinginmyopinion.Ifyouarehavingproblemsgettingontothis,trythisURL:
news://msnews.microsoft.com/microsoft.public.vc.mfcifthatdoesn'twork,tryadifferentemailreader,butpleasedon'temailus,wearenotinthebusinessofhelpingpeoplereadnewsgroups-sorry.
2.2.4.OtherFAQsofinterest
WindowsFAQ-MaintainedbyTomHaapanen.
ftp.metrics.com:~/faq
ExplainslotsofgreatstuffaboutWindowsthatyouwon'tfindhere.
WindowsProgrammingFAQ-MaintainedbyTomHaapanen.
ftp.metrics.com:~/faq
AwesomeWindowsProgrammingFAQ.Ithinkit'sbeenresurrectedbyanewfellowunderTom'swatchfuleye.Keepaneartothenewsgroupsforthedetails.
C++FAQ-MaintainedbyMarshallCline.
news:/news.microsoft.comnews://msnews.microsoft.com/microsoft.public.vc.mfcftp://ftp.metrics.com:~/faqftp://ftp.metrics.com:~/faq
ftptortfm.mit.edu:/pub/usenet/comp.lang.c++,alsooncomp.lang.c++
ThisisanawesomeFAQ,answerseveryC++questionyou'deverconceiveof.It'snotspecifictoMSVCsobecareful,somebehaviorcouldbedifferent.Theseguyshaveabookoutonit.
WinHelpFAQ-MaintainedbyPeteDavis
Postedregularlytocomp.os.ms-windows.programmer.winhelpIfyouhaveaquestionabouttheWindowshelpsystem,thisisforyou.
WindowsNTFAQ-MaintainedbyAdamHamilton
Postedtocomp.os.ms-windows.nt.misc?Prettygood,lotsofnetworkingstuffinthere.
2.2.5.FTPsites
There'snotmuchMFCcodeoutthere.Youcancheckoutthesesites:
ftp.microsoft.com-HasalltheknowledgedatabasesandacoupleofMFCspecificthings.Checkoutthesoftwarelibrarytoo(softlib).ftp.cica.indiana.edu-pub/pc/win3/progrmrwuarchive.wustl.edu-Goodsite,don'tknowaboutMFCstuff.pub/win3/progrmmrftp.uu.net-/vendors/microsofthassomedevelopersupportthingsthatareonbothftp.microsoft.comandCompuServe.Microsoftseemstobemovingawayfromhere.oak.oakland.edu-(SimTelMirror)SimTel/win3/pgmtools
Ifyoudon'thaveInternetaccess,youcanorderCD-ROMswiththeseentirearchivesfromWalnutCreek.Call(800)786-9907or(510)947-5996formoreinformation.
2.2.6.TheMFCFAQFTPArchive!
We'vestartedaMFCFAQFTParchive.ThisarchivecontainsMFCsamplesthatillustrateFAQsandpreviousreleasesoftheMFCFAQ.
ftp://ftp.microsoft.comftp://ftp.cica.indiana.eduftp://ftp.uu.netftp://oak.oakland.edu
ftp://ftp.stingray.com/pub/stingray/mfc_faq
Tosubmitasample,uploaditintothemfc_faq/incomingdirectoryandsendanemailtomfc_faq@stingray.comexplainingthesubmission.
CurrentlytheMFCFAQFTPArchivecontains:
multdocs.zip-ShowshowtohavemultipleCDocuments.multview.zip-Showshowtohavemultipleviews.onetime.zip-Howtorestrictyourapplicationtooneinstance.dlgcbr.zip-Howtoputcontrolbarsinyourdialogs.
%%TODO-Updatethesesamplesfor5.0-someone?anyone?Bueller?Bueller?Bueller?Thesewerelostwhenthelandru.unx.comaccountdisappeared,anyonehavethem?
ftp://ftp.stingray.com/pub/stingray/mfc_faqmailto:[email protected]
2.3.CompuServe
CompuServe,wellhowcanIsaythispolitely-sucks!Don'twasteyourtime.
2.4.PrintedMatter
2.4.1.Magazinesandjournals
Ok,ok,ok,Iadmitit!I'maMAGAZINEJUNKIE!There'sjustnobetterplacetopickupagoodlittlenuggetofMFCinfothanawellwrittenrag.IthinkIgeteverymagazineonthislistandmore.Here'salistofallmagsIknowofwithmyreview.Pleasefeelfreetosubmitanyreviewsyouhaveofmagazines-it'salwaysasubjectivekindofthing.
I'vetriedtolisttheseinorderofMFCcontent.TheonesfirsthavethemostMFCcontentwiththeoneslasthavingtheleast.Eventhoughtheydon'tdirectlycoverMFC,mostoftheWindowsprogrammingmagazinesarestillprettyvaluable.AnyofthesethatI'veread,Iputcommentswith.Ifyou'dliketocomment,emailmeandI'llthrowitinhere.Pleasedon'ttellmeaboutmoremagazines-I'llgobroke.
VisualC++DeveloperPinnaclePublishing($149/yr)(800)788-1900voice(206)251-1900voice(206)[email protected]://www.pinpub.com/vcd/home.htmMyfavorite,verymeaty,lotsofMFCcoverage.Theyhavehadarockyyear,butappeartobebackontracknow.
VisualC++Professional
OakleyPublishing($149/yr)(800)234-0386(503)747-0800
Similartoabove,butjustasmidgelessMFC.
MicrosoftSystemsJournal(MSJ)
MillerFreemanInc.
http://www.pinpub.com/vcd/home.htm
(800)666-1084(303)678-0439http://www.microsoft.com./msj/
VisualProgrammercolumnisEXCELLENT!!!!
Dr.Dobbs
MillerFreemanInc.(800)456-1215(303)678-0439http://www.ddj.com
Checkoutthe"UndocumentedCorner"forthecontinuingadventuresofGeorgeandScot'swildMFCInternalsexplorations.Ok,it'snotthatexciting,butitisaliving.
Windows/DOSDevelopersJournal
MillerFreeman(913)841-1631
ContinuingtoaddstrongMFCmaterial-gettingbetter!
C/C++UsersJournal
MillerFreeman(913)841-1631
NotmuchMFCspecificstuffatall,language-yarticles.
C++Report
SIGSPublications(800)361-1279(212)242-7447
Greatifyouwanttolearnaboutthedynamicsofinstantiated,real-timetemplatesasappliedtogenericprogrammingandpatternsinmodern-dayCASE/UNIXbasedGNUcompilers.Don'ttheseguyshavedayjobs?
http://www.microsoft.com./msj/http://www.ddj.com
2.4.2.BooksonMFC
There'stonsofbooksonVisualC++,butnotmanyofthemgointothedetailsaboutMFC.Here'salistofbooksthatareover50%orientedtowardsMFC(e.g.don'thavepagesofscreenshotsofcompileroptionsdialogsandtheMSVCIDE)
MicrosoftVisualC++DocumentationSetMicrosoftPressMSPRESS(416)293-8464Volume2:ProgrammingwithMFCandWin32($27)ISBN1-55615-802-5Volume3:MFCLibraryReference($45)ISBN1-55615-801-7
Thesecomeintheon-linedocs,butnicetohaveprintedversionsofthem.IfyouaregoingtodoMFCprogramming,volume2isa'musthave'
InsideVisualC++,Fourthedition
MicrosoftPress($45)DavidJ.Kruglinski(Ex-Microsoftie)ISBN:1-55615-661-8http://mspress.microsoft.com/
ISBNis1-55615-891-2SoundslikeitwouldbeVisualC++specific,butthisisthe'PetzoldofMFCprogramming.Inotherwords,it'sa'musthave'(alongwithvolume2oftheprinteddocs.Ifyoucan'taffordboth,stickwithvolume2on-lineandgetthisone)
**Note,theMFC/VC++5.0version(fourthedition)justhitthestreets-itlooksprettygood.-seelastcommentforthescooponthelatestversion.Donotbuythethirdorsecondedition,itisbird-cagelineratthispoint.RumorhasitthatDavidpassedawayrecentlyinafreakhanglidingaccident.Doesanyoneknowifthisistrueornot?!
ThebestMFCbookthatIknowofis"InsideVisualC++"byDavidKruglinski.Despitethename,thisisprimarilyanMFCbook.ChrisMarriott,[email protected],programmer.graphics,6/15/95
http://mspress.microsoft.com/
IownedthepreviousversionofInsideVC++andlearnedalotaboutMFC[ednote-henowhasthethirdNEWversion].ThiswasthebookthatgotmestartedinMFCprogrammingandIhaverecommendedittoeveryonewhoasked.Irecentlyboughtthelatesteditionandmyimpressionsareasfollows:-ItstillisTHEbookforSDKprogrammerswhowanttolearnMFC.-ItsstrongsuitisthecoverageoftheDocument/Viewarchitechure,printingandprintpreviewandon-linehelp.-Itisweakinit'scoverageofWindowscontrols(CListCtrl,CTreeCtrl,etc,etc)Ididnotfeelthatthenewmaterialitcontainedjustifiedthealmost$50.00pricetag,however.Irecommendthatanyonewhoownsanearliereditionofthebookspendalittletimeinthebookstorewiththis3rdeditionbeforetakingithome.-BlaineAndersonBlaine.Anderson@msfc.nasa.gov,mfc-l,1/14/96
TheRevolutionaryGuidetoMFCProgrammingWROXPress($45),June1996MikeBlaszczakISBN:1-874416-47-8http://www.wrox.comNOTE:Asecondeditionofthisbookisout,ithasMFCinthetitle,theoldonehasWin32inthetitle.ThisismypersonalfavoriteMFCbook(wellnexttoMFCInternalsofcourse…)[email protected]++and_some_windowsprogrammingthisisagreatbooktolearnMFC.ShelleyLambert,[email protected],programmer.tools,6/18/95ItisthebestbookonWin95programmingIhavefound.GaryCoombs,[email protected],programmer.win32,6/19/95
MFCInternals-AWGeorgeShephardandScotWingo
http://www.wrox.com/mailto:[email protected]
AddisonWesley$39.95GeorgeShepherdandScotWingoISBN:0201407213http://www.aw.com
Thisbookisbestdescribedasthe'otherside'oftheMikeBbook.WhereMikeshowsyouhowtouseMFCatanadvancedpace,weshowyouhowMFCworksunderthehood(alsoatanadvancedpace).Ifyou'veevergottenlostintheMFCsource,you'llknowwhythisis*extremely*helpfulinformation.Plus,it'sMFC4.0soit'sprettydarncurrentinformation.CheckouttheMarch"UndocumentedMFC"columninDr.Dobbsforasneakpeekatthebook.-scot@stingray.com-co-author."Quitesimply,thisbookisamust-haveforanyseriousMFCdeveloper."
""Thisbookisdefinitelynotarehashofexistingdocuments.Itisnota"how-to"book-itisa"howdoesitwork"book."-DeanMcCrory-technicaleditor,leadoftheMFCteam.
WritingWindowsApplicationswithMFC
M+TBooks($40)BryanWatersISBN:1-55851-379-5
AtfirstIthoughtitwastoobeginner,butthelast5chapterskickbutt.LotsofinfoonMFCinternals,exceptionhandling,andtopicsnotcoveredelsewhere.GoodforsomeonenewtoWindowsandMFCprogramming.-notupdatedtocover4.0.
VisualC++How-To:TheDefinitiveMFCProblemSolver
WaiteGroupPress($40)Apr-95,570pagesInfo:http://www.dnai.com/waite/(800)788-3123(510)658-3453ScottStanfield,RalphArveson,AlanLight&MickeyWilliamsIncludesaCD-ROMISBN1-878739-82-4
http://www.aw.comhttp://www.dnai.com/waite/
Note:NotupdatedforVC++4.0.
Icantellyouthatitsarealgoodbookforwhatitsintendedtobe.Whichis,sortoflikeyourFAQ.ItcomeswithaCDandhaslittletidbitslike:
1. Howtoanimateanicon.Iadaptedthisabittofigureouthowtochangeicons(inanMDIonthefly).
2. HowtodetectmultipleinstancesofaWindowsappandpulltheotheronetothetopoftheZ-order.ThisisaperennialUsenetquestionandIpulledthecodeandhaditworkingfirsttime.
3. HowtoputabitmaponthemainclientwindowofaMDIapp.Again,anastylittlethingtofigureoutonyourown,butgivengooddirections,quiteeasilydonefromthebook.
TheCDisalsobrokenoutbetweenthosethatareusingVC1.5versus2.0.LikeotherWaiteGroup"How-To"programmingbooks,thisoneisin"Cookbook"orFAQformat.Youreadthetableofcontentsforthefunctionalityyouarelookingfor,andtheassociatedchaptercontainsthecodetoimplementit.Topicsinclude:
DocumentandView,StatusBarsandToolbars,Controls,Multimedia,BitmapsandIcons,DialogsOLEandDDE,SystemandaFAQofshorttips.ManynewclassesaregivenherewhichallsupplementtheMFCinafairlylogicalmanner.Someofthechapterswhichwereofinteresttomewere:2.1-Putthecurrenttimeinthestatusbar2.3-AddastatusbartomyViews2.4-DisplayProgressinformationinthestatusbar4.1-PreviewanAVIfileusingthecommonfiledialog4.3-PlayAVIfilesinaCView4.4-PlaylargeWAVfiles4.6-Create3DanimationusingOpenGLandMFC5.5-Smoothlyanimatebitmaps6.6-WritecustomizedDDX/DDVroutines8.3-LocalizeMFCapplicationsusingresourceDLLs8.5-MakemultipleinheritanceworkinMFCAndmanytidbitsfromtheFAQ...
Ilikethecookbookformatwhichallowsmetoglueinspecificfunctionalityondemand.Ifoundthisbooktobefairlyhelpfulinthatregard.IlookforwardtoVolumeIIcntrline@winnet.comviaemail,7/15/95
VisualC++2:DevelopingProfessionalApplicationsinWindows95andWindowsNTusingMFC
MarshallBrainandLanceLovettePrenticeHallISBN:0-13-305145-5
Note:NotupdatedforVC++4.0.
ThiswasthethirdMFCbookIpickedup,andbyfarthebestone.LikeBrain'sotherbooks(HeartofNT...)thisonesetsouttoanswersomefrequentlyaskedquestions,asenumeratedintheintroduction.It'sdefinitelyacomprehensivebook,dividedintofivesectionscoveringthebasicsofVisualC++andMFC,Controls,UsingtheAppWizardwithMFC,ProfessionalFeatures,andAdvancedMFCclasses.IthasaninterestingappendixthatisdesignedtogetCprogrammersuptospeedwiththeC++conceptsthattheywillneedtouseMFCrightaway.ItdoescoverthingslikeOLE,ODBCandThreadsaswellassome'examplechapters'coveringthingslikesplashscreens,andmultipledocumenttemplatesperapplication.It'sprettycoolbecauseitgoesthroughMFCwithouttheClass/AppWizardsbeforeintroducintthemtoyou.It'sveryclear,andmosteverythingisdonebyexample,whichIreallylike;).Whatitdoesn'tdoiscoveranyofthenewcommoncontrolsdespiteitstitleimplyingWindows95development.Thisseemstobeok,becauseNancyCluts'booklookslikeitshouldhandlethatpartwellenough;)Ihighlyrecommendthisone,especiallyifyouhavepreviouswindowsprogrammingexperienceandarelookingtomigratetoMFC3.xfor95/NT.
Topicsofinterest:
UnderstandingMessageMaps,DebuggingandRobustness,DynamicDataExchangeandValidation,HowMFCWorkswithWindows,CreatingaSelfDrawingControl,PropertySheets,OLE,MFCThreads,CombiningTwo
DocumentsandViewsinaSingleApplication,SubclassingandWindowsProcedures,aswellasthestandardtreatmentofeverycontrolfromedittocomboboxes.
NigelThompsonMicrosoftPress(Early1995)ISBN:1-55615-669-3
Atfirstglance,Iignoredthisbookontheshelves,however,whenIfinallypickeditup,itusedMFCcompletelythroughout.AverygoodbookondoinggraphicswithMFC.jdc@biosym.com,JohnClark,viaemail6/6/95
TeachYourselfMicrosoftFoundationClassLibraryProgrammingin21Days
RobertShawSAMS($30)ISBN:0-672-30462-7
Note:NotupdatedforVC++4.0.
Ifind"TeachYourselfVisualC++in21Days"agoodreference,sinceitissetuptocoverasmallgroupoffeatureseach"day",soyoucanquicklygotoasubjectarea,andgetafrom-scratchdescriptionofitandhowtouseit.However,theauthorisnotstrongonusingtheVCIDE,claimingthat"youhavetowritethiscodeyourselfthefirstfewtimes,soyoubetterappreciatewhatAppStudioandClassWizardaredoingbehindthescenes."I'dprefertheapproachwhereweusethetoolsathand,andthenmapoutwhatthosemagicMESSAGE_MAPmacrosarereallydoing.Paul.McGuire@SEMATECH.Org,email,7/11/95
RobertShaws`bookisterrificforthebeginnerlearningMSVCandMFC.Beforetryingouttheexamplesfoundwithin,downloadtheupdatedfilesviaftpfromtheaddressspecifiedinthebook.Thiswillsaveyoualotoffrustration.Theexamplesarewellthoughtout.ThisbookisbetterthatSteveHolzner`sseriesofbooksonOLEorMFC(whatisn't?).Oncea
mailto:[email protected]
beginnerhasfinishedwiththisbookheisreadyformoreseriousbookssuchas"InsideVisualC++"[email protected]
MSFoundationClassPrimer:ProgWindows3&WindowsNTw/MFC
JimCongerTheWaiteGroupPress($32)Mar-93,830pagesISBN:1-878739-31X
Note:NotupdatedforVC++4.0.
ThebestMFCbookthatI'veseenthatDOESN'TuseVC++WizardsisMicrosoftFoundationClassPrimer.stasic@news.dorsai.org,ED,programmer.misc,6/24/95ThisbookisagoodintroforpeoplenewtoMFC,butit'sgettingprettydated.ThisbookwaswrittenduringthetimeofMSC++7.0,andsomeofthenewestfunctionalityjustisn'tcovered(forobviousreasons;),whichcanconfuseanewbie.Atanyrate,it'sstillmakesprettygoodbookforsomeonelookingforthebasics.cntrline@winnet.com,email,7/15/95
MasterVisualC++2,2/Ew/CD-ROM(coversMFC3.0library)
HowardW.Sams&Company($50)Jan-95,1183pagesGurewich&GurewichISBN:0-672305-321Note:NotupdatedforVC++4.0.Ipickedupacopyof"MasterVisualC++"specificallyforitscoverageofcreatingcustomVBX's.ThisisnotcoveredinKuglinski's"InsideVisualC++"norin"TeachYourselfVisual-C++in21Days"."MasterVisualC++"isjustmyspeed,sinceIamadabblerwhodoesnotreadinstructionsortutorials,justjumpsinovermyhead,thenstartslookingfortheroutinecallsIoverlooked.SimilartotheHeavyMetalbook,thisbookcouldhavebeensqueezeddowntoabout1/3thesize,butherethatisnotthepoint.Eachexamplestartswithademoofthefinishedproduct,thengoesthroughthestepsdescriptively,thengoesthroughthestepsagainwiththecode.MylittleVBXwasdoneinadayanahalf,andIhaveamuchbetterfeelforthe
mailto:[email protected]
[email protected],email,7/11/95
HeavyMetalVisualC++Programming
SteveHolznerBradyPublishingISBN1-56884-196-5
Note:NotupdatedforVC++4.0.
Hatetodisagree,butIfindthisbookdisappointing.Thereasonis,Ifeltlikebeingtreatedasasemi-idiotwhenreadingthebook.Don'tgetfooledbyitsnumberofpages,itcouldhavebeeneasilyreducedtohalfofitssize,iftheauthorknewhowtolistthecodeefficiently.Furthermore,therearetoomanymisprintsintheversionIhave.Huayong([email protected]),programmer.tools,6/18/95TheruleofthumbisneverbuyHolzner'sbook.Hisbookonlyleadsyouthethedoor.Youcan'tfindpracticallyusefulexamples.Almosteveryupdatedvesionisthesame.Runhong([email protected]),programmer.tools,6/18/95
ProgrammingtheWindows95UserInterface
MicrosoftPress($34.95)ISBN1-55615-884-XNancyCluts
NOTE:MicrosoftDeveloperNetworkDeveloperLibrarycontainsthecompletetextofthisbook.Mightwanttocheckitouttherefirstbeforebuyingit?
%%TODO-getareview!
VisualC++PowerToolkit
VentanaPress($50),1995,785pagesInfo:http://www.vmedia.com/vc++.html(919)942-0220RichardLeinecker,JamieNyeIncludesaCD-ROM
ISBN1-56604-191-0
Note:NotupdatedforVC++4.0.YACTB=YetAnotherCookbookTypeBook.Althoughthisbooktriestobeasourcebookforprogrammersbygivingmanynewclassesandclevercode,itjustisn'tlaidoutaslogicallyasotherbooksI'veseenrecently(see:"VisualC++How-To"listing).Thisbookcoversalotoftopics,suchas:CustomizingtheInterface,Animation,ScreenEffects,Music&Sound,AdvancedAnimation,DataCompression,OLE2.0,CommunicationsandScannerInput(UsingTWAIN).Ihaven'tfoundthisbooktobeasusefulasotherbooksformypurposesyet,butitdoesincludealotofnewClasseswhichmayproveusefulforotherprogrammers.cntrline@winnet.com,email,7/15/95Ijustgrabbedthisoneandatfirstglanceitlookedreallyuseful,thenIstartedreadingitandBLECH!Theauthor'swritingis,well,it'snotsogreat.Also,theclassesaresloppyandshownoOOdesignatall.Theauthor'scommentis"I'mnothungarian,sowhyshouldInamevariableslikeone".Can'[email protected]
ThefollowingarerumoredtobecomingoutRSN(Realsoonnow)
MFC4.0Bible-TheWaiteGroup($45)
ExtendingMFC-AWDavidShmitt
ProgrammingWindows95withMFC,MicrosoftPress,JeffProsise%%TODO-getreview,Ithinkthisisout.
UPD!!2.4.3.CoolMFCArticles
There'sprobablyamillion'good'MFCarticlesoutthere,butthissectionisfortheultra-hip,totally-swinging,must-have,gotta-readMFCarticles.Ifyousubmitanarticleforthissection,pleaseincludeallthe'volume'informationandashortparagraphaboutwhyit'ssodamncool![NoteifyouhavequestionsaboutthemagazinesorMSDNmentionedbelow,seesections:2.4.1and2.1.2]
"FunwithMFC:33TipstoHelpYouGettheMostOutof..."Paul
mailto:[email protected]
DiLascia,MSJ,November1993,Volume8,Number11
ThisismyA#1MFCarticleofalltime.Eventhoughthisarticleis2yearsold,ithasprincipalsandideasthatareextremelyvaluabletotoday'sMFCprogrammer.Goodnewsisthatit'sonMSDNintheirMSJarchives!Youcanalsofindthisgemunderbooksonline:Extensions:articles/TechnicalArticles/FunwithMFC:[email protected]
"MeanderingThroughtheMazeofMFCMessageandCommandRouting"PaulDiLascia,MSJ,July1995,Volume10,Number7
Bestexplanationofmessagesever,aMFCFAQ"must-read".
"RewritingtheMFCScribbleProgramUsinganOODApproach"AllenHolub,MSJ,August1995,Volume10,Number8.
Notmyfavoritearticle,but'DID'stiruplotsoftalkonmostMFCforums.Anyarticlethatgeneratesthismuchnoisehastobegood.
"SelfDecoratingPages"DavidA.Schmitt,WindowsTechJournal,July1995"Dad,CanIDrivethePrinterTonight?"-DavidA.Schmitt,WindowsTechJournal,August1995
Thisseriesofarticlesisprettygood,especiallyifyouareintoprinting.
"PlungeintoMFC'sUserInterface"ScotWingo,WindowsTechJournal,August1994
StuffbyMFCFAQmaintainer:
C++Report,SIGSPublications,"ABriefHistoryofMFC"-recapssection3ofthisFAQandthrowsinsomenewinformation.Dr.Dobbs,January1996,"ExtendingMFC"-describesanMFCgridextension.WindowsTechJournal,November1994,"AllaboardtheMFCExpress"WindowsTechJournal,August1994,"PlungeIntoMFC'sUserInterface"
%%TODO-ComeonMFCFAQreaders-let'sgetsomenewsubmissionsin
http://www.stingray.com/~scot/wintech3.htmlhttp://www.stingray.com/~scot/wintech2.html
thissection,gettingboring!
2.5.Tradeshows
VisualC++Developer'sConference
TherehavebeentwoUSconferencesputonbytheseguysandtheykeepgettingbetter.ThesearekindofmodeledafterVBITs,whereyouhaveveryfocusedtalksonVC++/MFC/ATL.Checkouthttp://www.vcdj.com.Wereallyhighlyrecommendthisshowsinceitisslowlybecomingtheonlyplaceforraw,uncensoredMFC/VCinformation!
SoftwareDevelopment(EastandWest)
MillerFreeman(415)905-2222http://www.mfi.com/[email protected]/VCisconcerned.Internetinternetinternet-sigh!
http://www.vcdj.com/mailto:[email protected]
2.6.UsersGroups
Idon'tknowofanyMFCspecificuser'sgroups,buttherearesomereallygoodC++user'sgroupsthathavesomeMFCcontentintheirprograms.TheNWC++User'sgrouphasareallyniceemailnewsletterthatanybodycansubscribetobyemailingcpp@netcom.com.Here'sthecontactinformationfortheknownC++User'sgroups
%%TODO-addinformationonDCVC++group.
Area ContactName ContactEmailNewYork,NY SaulRosenberg [email protected],WA SteveShimeall [email protected],CA GenePaymar [email protected],CA MarianCorcoran [email protected],AZ MartinLapidus [email protected] RobinRowe [email protected],MA JohnBarrie [email protected]
2.7.TechnicalSupport
MicrosoftMSVCTechnicalSupport(206)635-7007
NEW!!2.8.MFC/VC++RelatedCompanies
DevelopMentor-Simplythe*BEST*developertrainingcompany.ExcellentMFC/OLEofferingstoo.Microsofthomepage-YoBILL!What'sup?!NU-MEGA-Thepenguinguys.XtrasforVisualC++-CompanythatsellsVisualC++add-ons.TheDevelopmentExchange-TheguysthatdoVBPJandtheMicrosoftcatalogs.
http://www.develop.com/dm/default.asphttp://www.microsoft.comhttp://www.numega.comhttp://www.xtras4vc.comhttp://www.devx.com/default.asp
3.ABRIEFHISTORYOFMFCIconstantlyseepostingsfromfolksconfusedaboutwhatversiontousewhere,etc..SothishistorykindofexplainswhereMFChasbeenandwhereit'sgoing.[ThisisthehistoryasIrememberit.Ifyouhaveanydetailsthatyoucanfillin,releasedates,insideinfo,etc..Letmeknow!]
TounderstandtheMFCreleases,youneedtorealizethatthereare16and32-bitreleasesofMFC.16-bitreleasescallWin16andrunonWindows3.1and3.11(WindowsforWorkgroups)
The32-bitreleasescallWin32andrunonWindowsNTandWindows95(andcanrunonWindows3.1withWin32s,butitstillcallsWin32)
Skiptosection3.13foraquicktableofreleasesifyouwanttoskipthelongdescriptionsofeachrelease.
Ineachsection,thenewclassesaddedtoMFCarehighlighted.It'snearlyimpossibletodocoolclassdiagramsinASCII,sotheirhierarchyisjustshownbyindentation.I'vealsoleftCObjectoutofmostofthehierarchiesforbrevity.YoucanprettymuchassumethatCObjectisaparentofmostoftheclassesexceptthingslikeCString,etc.
3.1.HowdoIknowwhatversionofMFCI'musing?
3.2.Pre-MFC1.0
3.3.MFC1.0
3.4.MFC2.0
3.5.MFC2.1
3.6.MFC2.53.6.1.MFC2.513.6.2.MFC2.523.6.3.MFC2.52b
3.6.4.MFC2.52c
3.7.MFC3.0
3.8.MFC3.1
3.9.MFC3.2
3.10.MFC4.0
3.11.MFC4.1
3.12.MFC4.23.12.1.MFC4.2b3.12.2.MFC4.21
3.13.TableofMFCReleases
3.1.HowdoIknowwhatversionofMFCI'musing?
CheckthetopoftheMFCheaderfileafxver_.h(livesinmfc\include\afxver_.h).Olderversionsuseafxver.h.Inthereyouwillseea#definefor_MFC_VER.
ThisisthehexversionoftheMFCreleasewiththiskey:
0x0250|_________Pointrelease(veryminor)|__________Minornumber|___________MajornumberSointhisexample,theMFCreleaseis2.5.0.
3.2.Pre-MFC1.0
Inthebeginning,MicrosoftcreatedagroupcalledtheAFXgroup(standsfor(A)pplication(F)ramework(X)).ThisgroupprobablywascreatedtocomeoutwithanOWLcompetitor,sinceBorlandC++wasdoingprettywell.TheycameupwithaclasslibrarythatpresentedaveryhighabstractionfromtheWindowsAPI,kindoflikeOWLdoes.
[Note:[email protected]]
LegendhasitthattheythenwentandtriedwritingapplicationswithitforacoupleofmonthsandfoundthatitwasjusttoofarremovedfromtheWindowsAPI.Theycouldn'tleverageanyknowledgeofWindowsandmostoftheseguyswerediehardWindowsAPIhackers.
LegendalsohasitthatatthispointtheyscrappedtheENTIREAFXclasslibrary,andthenworkedonwhatwouldbecomeMFC1.0...YoucanstillseeremnantsoftheAFXdays,manyofthesourcefileshaveafxprefixesandlotsofmacrosinMFCtodaystillhaveAFXinthem.
TheAFXgroupwasactuallyresponsiblefortwothings:theMFClibraryandtheIDE'ssupportforMFC(namely,theresourceeditorandthewizards).TheAFXnamewasdroppedinApril1994,andthegroup'smemberssimplybecamepartofsmallerteamswithintheVisualC++group.Oneofthosesmallerteamsistoday'sMFCteam.
I'vealsoheardrumorsthatMFCwasoncecalledtheMSFulcrumClasses.
3.3.MFC1.0
ThisreleasewassimultaneouslyreleasedwithMicrosoftC/C++7.0inearly1992.ItprovidedaverythinabstractionovertheWindowsAPI.Thisinitialreleasedidnothaveanyofthedocumentviewarchitectureweknowandlovetoday,howeveritdidlaythefoundationbyintroducingCObject,MFCpersistenceviaCArchiveandmanyotherfeaturesstillheavilyusedinMFCtoday.Thiswasa16-bitreleasereleasedin03/92.
A32-bitversionofMFC1.0wasreleasedinJuly1993,togetherwithWindowsNT3.1andthefinalWin32SDK.Thefilestherearedated93-07-24.TheWin32SDKdidnotincludeVisualC++ortheMFC2.x.
MFC1.0IntroducedTheseClasses:
General:
CObjectCWinAppCMenuCArchiveCDumpContextCRuntimeClassCMemoryStateCFileStatusCStringCTimeCTimeSpanCPointCRectCSize
Exceptions:
CExceptionCMemoryExceptionCNotSupportedException
CArchiveExceptionCFileExceptionCResourceException
FileServices:
CFileCStdioFileCMemFile
Collections:
CByteArrayCWordArrayCDWordArrayCPtrArrayCObArrayCStringArrayCPtrListCObListCStringListCMapWordToPtrCMapWordToObCMapPtrToWordCMapPtrToPtrCMapStringToPtrCMapStringToObCMapStringToString
Graphics:
CDCCClientDCCWindowDCCPaintDCCMetaFileDCCGdiObjectCPenCBrush
CFontCBitmapCPaletteCRgn
WindowsSupport:
CWndCFrameWndCMDIChildWndCMDIFrameWndCDialogCModalDialogCStaticCButtonCEditCListBoxCComboBoxCScrollBar
3.4.MFC2.0
MFC2.0wasa16-bitreleasethatshippedwithVisualC++1.0.ItaddedtheDocument/ViewframeworkontopofMFC1.0andalsoaddedOLE1.0classes,messagemapsandcommondialogclasses.Thiswasa16-bitreleasereleasedon02/93.
MFC2.0IntroducedTheseClasses:
General:
CCreateContextCPrintInfoCDataExchangeCCmdUI
Exceptions:
CFileExceptionCOleException
Dialogs:[NoteCModalDialogwasnukedandfunctionalitymovedtoCDialog,youcanstillseea#defineCModalDialogCDialogintheheaderfiles]
CDialog[notintroducedhere,butrevampedtobeabaseforcommondlgs]CFileDialogCColorDialogCFontDialogCPrintDialogCFindReplaceDialog
WindowsSupport:[JustnewderivativesofCButton/CEditandVBXclass.]
CButtonCBitmapButtonCEdit
CHEditCBEditCVBControl
DocumentArchitecture:
CCmdTargetCWinApp[Movedinhierarchy,usetobederivedfromCObject]CDocTemplateCSingleDocTemplateCMultiDocTemplateCDocumentCOleDocumentCOleClientDocCOleServerDoc
Views:
CViewCScrollViewCFormViewCEditView
ControlBars:
CControlBarCToolBarCStatusBarCDialogBarCSplitterWnd
OLE1.0Classes:
COleServerCOleTemplateServerCDocItemCOleClientItemCOleServerItem
3.5.MFC2.1
MFC2.1shippedwithVisualC++1.1forNT,itwasbasicallyaWin32portofMFC2.0.Itwasa32-bitreleasethatwasreleasedon08/93.
MFC2.1DidNOTIntroduceAnyNewClasses.
3.6.MFC2.5
MFC2.5shippedwithVisualC++1.5.ItintroducedtheOLE2andODBCclasses.Itwasthelast'official'16-bitrelease.Releasedin12/93
MFC2.5introducedtheseclasses:
General:[OLEandDBrelated]
CFieldExchangeCOleDataObjectCOleDispatchDriverCRectTracker
Exceptions:[OLEandDBexceptions]
COleExceptionCOleDispatchExceptionCDBException
Files:[NewOLEFilesupport]
CFileCOleStreamfile
Dialogs:[NewOLEDialogs]
CDialogCOleDialogCOleInsertdialogCOleChangeIconDialogCOlePasteSpecialDialogCOleConvertDialogCOleBusyDialogCOleLinksDialogCOleUpdateDialog
WindowsSupport:[SomeOLEadditions]
CFrameWndCOleIPFrameWndCControlBarCOleResizeBar
DocumentArchitecture:[SignificantclassesaddedforOLEhere.]
CCmdTargetCOleObjectFactoryCOleTemplateServerCOleDataSourceCOleDropSourceCOleDropTargetCOleMessageFilterCDocumentCOleDocumentCOleLinkingDocCOleServerDocCDocItemCOleClientItemCOleServerItem
Views:[NewviewforDBsupport]
CViewCScrollViewCFormViewCRecordView
ODBC/DatabaseClasses:
CDatabaseCRecordSetCLongBinary
3.6.1.MFC2.51
Apointreleaseto2.5(16-bit)thatwasabugfixrelease.ShippedwithMSVC2.0in9/94withMFC3.0(32-bit).
3.6.2.MFC2.52
Apointreleaseto2.5(16-bit)thataddedsomeoftheMFC3.0featuressuchaspropertysheets,WinsockandMAPIsupport.ShippedwithMSVC2.1in1/95withMFC3.1(32-bit).
NOTE:ThisisonlyavailableviatheMSVCSubscription.
Classesaddedin2.52:
CSocketCAsyncSocketCSocketFileCPropertyPageCPropertySheet
MAPI:[NotethatMAPIsupportwasaddedtoCDocument,nonewclasses]
CDocument::OnFileSendMailCDocument::OnUpdateFileSendMailCOleDocument::OnFileSendMail
3.6.3.MFC2.52b
[Excerptfromthe2.52breleasenotes]
VisualC++1.52bincludestheindustry-standardMicrosoftFoundationClassLibrary(MFC)version2.52b.BesidesclassesforOLEanddatabase,thisversionincludesclassesforOLEcontroldevelopment.
BugsFixedinVisualC++1.52b
VisualC++1.52bfixesanumberofbugsfromVisualC++1.5.Ofparticularinteresttomostdevelopersarethefollowingbugfixes:
MFC2.52b
ErrorL2025occurredonCWnd::DoDataExchange.Thisbughasbeencorrected.SeeMicrosoftKnowledgeBasearticleQ120152formoreinformation.
CArchive::ReadObjectsometimescausedanassertioninaCPtrArrayobjectbecauseCPtrArraycanholdamaximumobjectsizeof16Kinalargememorymodelapplication.CArchivedidnottakethememorymodelintoaccount;sinceCArchiveenforceda32Klimit,objectsof32KcouldbewrittenbutanassertionwasgeneratedifCArchivereadinmorethan16K.Thisbughasbeencorrected.
Therewasamemoryleakin16-bitAUX_DATA.
ThethreepensusedintheclassCPropertySheetwereleaking.SeeMicrosoftKnowledgeBasearticleQ128604formoreinformation.
TheCArchivebufferpointercouldwraparoundtheendofasegmentunintentionally.Thisbughasbeencorrected.
IfAfxSockInitfailed,applicationssometimesproducedaGeneralProtectionFault.Thisbughasbeencorrected.SeeMicrosoftKnowledgeBasearticleQ130653formoreinformation.
TheMAPISendMaildialogdidnotstaymodal.Thisbughasbeencorrected.
SourcefileDLGPROP.CPPhadnon-neardata.Thiscouldpreventapplicationsfrombeingabletorunmulti-instance.Thisbughasbeencorrected.
3.6.4.MFC2.52c
Thisbug-fixreleaseshippedwithVisualC++4.0onaseparateCD-ROM.
%%TODOcheckreleasenotesfordetails-isanyonestillusingthisstuff?
3.7.MFC3.0
MFC3.0shippedwithVisualC++2.0in9/94.Itintroduceddockingtoolbars,propertysheetsandtemplatebasedcollectionclasses.ThiswasthefirstreleaseintheMSVCsubscription,itwasa32-bitrelease.
ClassesaddedinMFC3.0:
TabbedDialogSupport:
CWndCPropertySheetCDialogCPropertyPage
3.8.MFC3.1
MFC3.1shippedwithVisualC++2.1in1/95.ItintroducedMAPI,WinSockandWindowsCommonControls.TheMFCtoolbar,statusbar,etc..stillliveinMFC.Thisisthelatestreleaseout.Itisa32-bitrelease.
NOTE:OnlyavailableviaMSVCsubscription.
ClassesAddedinMFC3.1:
MAPI:[NotethatMAPIsupportwasaddedtoCDocument,nonewclasses]
CDocument::OnFileSendMailCDocument::OnUpdateFileSendMailCOleDocument::OnFileSendMail
WindowsCommonControlsClasses:[AlloftheseareCWndderived]
CAnimateCtrlCHeaderCtrlCHotkeyCtrlCImageListCListCtrlCProgressCtrlCSliderCtrlCSpinButtonCtrlCStatusBarCtrlCTabCtrlCToolBarCtrlCToolTipCtrlCTreeCtrl
WinSockSupport:
CAsyncSocketCSocket
3.9.MFC3.2
MFC3.2shippedwithVisualC++2.2viathesubscriptioninmid/lateJuly.Itisa32-bitrelease.Includesa2.52b16-bitreleaseupdate.
[here'sanexcerptfromthereleasenotes]
SupportforWindowsCommonControlsinUSRDLLs.InordertousetheMFCWindowsCommonControlclassesyoumustlinkintheappropriatestaticlibraries,asshowninthefollowingtable:
Library TargetDAFXCC.LIB ReleaseVersionDAFXCCD.LIB DebugVersionDAFXCCU.LIB ReleaseUnicodeVersionDAFXCCUD.LIB DebugUnicodeVersion
UpdatedMFCCommonControlclassesthatworkwiththosecontrolsthathavebeenrecentlyreleasedinWindowsNT3.51andthosethatwillbeavailableinWindows95andafutureversionofWin32s.
Improvedcommoncontroldocumentationthatismorecompleteandreflectschangessincethefirstimplementation.
NewMFCsampleapplications
NOTEPAD+Notepad+isanenhancedversionofNotepad.Theenhancementsaremainlyfromquestionsourcustomershavebeenasking.SAVERSaverisascreensaverwrittenusingMFC.It"morphs"thetext"MFC"tothetext"C++".OLEVIEWTheOLEVIEWsampleisverysimilartotheOLE2VIEW.EXEappletprovidedin\MSVC20\BIN.ThesampleillustrateshowtoimplementOLEObjectviewersthroughcustomOLEinterfaces.ThesecustominterfacesareimplementedinIVIEWERS.DLLBATCHBATCHisanMDIapplicationthatletsyoucompressdifferentAVI(AudioVideoInterleaved)filesindifferentways.
WORDPADWORDPADillustratesuseoftheCRichEditCtrlandCRichEditViewclasses,whichencapsulatethenewRichEditcommoncontrol.
ThesesamplesarelocatedintheSAMPLES\MFCdirectoryofyourVisualC++installation.
UpdatedWin32SDKComponents
WiththereleaseofWindowsNT3.51andtheupcomingreleaseofWindows95,theWin32SDKhasbeenupdatedtosupportbothoftheseoperatingsystems.Changesincludenewheaderfiles,newimportlibraries,andadditionaldocumentation.VisualC++2.2includesthelatestheaderfiles,importlibrariesandWin32APIdocumentationtosupportwritingWindowsNT-andWindows95-compatibleapplications.
3.10.MFC4.0
MFC4.0wasreleasedwithVisualC++4.0inNovemberof1995.MicrosoftskippedfromVisualC++2.2to4.0tosynchronizenumbers,whichtheylaterbrokeinVC++5.0,butthat'slifeIguess.
ClassesaddedinMFC4.0:
CSynchronizeCMutexCEventCMultiLockCShellNew-Windows95
VisualC++4.0alsoincludesthecomponentgallery,STLsupportandtonsofnewfeatures.CheckouttheMicrosoftWWWforthedetails.
SeeFAQsection11.24and13.7forMFC/VC++4.0-specificquestions.
3.11.MFC4.1
ThemostimportantthingaboutthisreleaseisthatitisthelastreleasethatsupportsWin32s.TherearetonsofMFCdevelopersstuckonthisrelease,soifyouseesomeonepostingthattheyareusingMFC4.1,thatisprobablywhy.Thisfixedmanyofthe4.0bugsandaddedsomenewInternetfeatures.
%%TODO-getthedateandamorecomprehensivelistofwhatwasnew.Can'trememberifISAPIwasinhereyet,butI'mprettysureithadthe"sweeper"stuff-HTTP,gopherandftpclasses.
3.12.MFC4.2
ISAPIclassesaddedandactuallyusableOCXcontainersupport(stillupfordebateIMO).
%%TODO-getthedateandmorefeatures.
3.12.1.MFC4.2b
MFC4.2hadnumerousbugsintheareasoftheInternetclasses,OLEcontrols,etc.
%%TODO-again,morespecifics.
3.12.2.MFC4.21
ReleasedonMarch19,1997aspartofVisualC++5.0,thisisthelatestandgreatestMFCrelease.TheonlynewfeatureaddedtothisreleaseisIntelliMouse™supportwhichevidentlytookthebetterpartofanafternoonfor.BekiMtobangout.ThisreleasealsoincludesanotherroundofbugfixesandIwouldsayisbyfarthemoststableMFCsince3.2(thisisduetoallofthenewfeaturesadded,whichisunderstandable).
Unfortunately,wenowhaveasituationwheretheMFCreleasedoesn'tmatchVC++-everybodyonthenewsgroupsthinkstheyareusingMFC5.0,whichdoesn'texist.Helpmesetthemstraight!!
3.13.TableofMFCReleases
Hint,MFCreleasesarealwaysMSVCrelease-1.ThisisbecauseMFC1.0cameoutwithMSC7.Thiswasallchangedwith4.0ofcourse,nowtheformulaismucheasier:MSVCrelease=MFCrelease,welluntilVC++5.0cameout.
MFCRelease MSVCRelease 16or32Bit Notes
1.0 16 JustthinWindowscoverage2.0 1.0 16 Document/Viewsadded2.1 1.1forNT 32 First32-bitreleaseforNT2.5 1.5 16 OLE/ODBC,last16-bitrelease2.51 2.0 16 BugFixes2.52 2.1 16 AddsPropertySheetsto2.52.52b 2.2 16 ShippedinJuly'95,bugfixes2.5c 4.0 16 ShippedinNov'95,bugfixes3.0 2.0 32 Propertysheets,docktoolbars3.1 2.1 32 Winsock/MAPI,Wincomctrls3.2 2.2 32 ShippedinJuly'95,morecomctrls
4.0 4.0 32 Win95,threadclasses,OCXcontainers
4.1 4.1 32Tonsofbugfixes,sweeper(WinInet)classes.WaslastreleasetosupportWin32s.
4.2 4.2 32 Morebugfixes,ISAPIclasses4.2b internetdl 32 Lots-o-bug-fixes!4.21 5.0 32 IntelliMouse™support.
4.ExceptionHandling4.1.CException-ExceptionsandExceptionHandling
4.1.1.HowdoIthrowaCUserExceptionderivedexception?4.1.2.DomyexceptionshavetobederivedfromCUserException?
4.1.CException-ExceptionsandException-handling.
4.1.1.HowdoIthrowaCUserExceptionderivedexception?
WhenItrytocatchaderivedexceptionIgetthefollowingerror:errorC2039:'classCMyException':isnotamemberof'CMyException''classCMyException':undeclaredidentifier'IsKindOf':cannotconvertparameter1from'int*'to'conststructCRuntimeClass*'
YouneedtomakeyourCMyExceptionclassdynamicallycreatableusingtheDECLARE_DYNAMIC()andIMPLEMENT_DYNAMIC()macros.TheCATCHmacroexpectstobeabletoaccessrun-timeinformationaboutthethrownclass.
[email protected],MikeB,6/5/95,comp.os.ms-windows.programmer.misc
4.1.2.DomyexceptionshavetobederivedfromCUserException?
No:The"User"inCUserExceptionsimplymeansthattheexceptioniscausedbyuseractions.Itisacommonmisperceptionthatthisistheonlyexceptionyoucanderivefrom.
[email protected]/23/95
5.GDIClassQuestions5.1.CDC
5.1.1.HowdoIcreateaCDCfromaHDC?5.2.CBitmap
5.2.1.HowdoIreada256colorbitmapfilefromdisk?
5.1.CDC
5.1.1.HowdoIcreateaCDCfromaHDC?
SometimestheWindowsAPIwilljustgiveyouahandletoaDCandyoumightwanttocreateaCDCfromthat.Oneexampleisowner-drawnlists,combos,andbuttons.YouwillreceiveadrawitemmessagewithahDC.Here'ssomecodetoturnthathdcintothemorefamiliarCDC.
YoucanusethistechniqueforanyoftheotherMFCclass/Windowshandlepairstoo.
voidMyODList::DrawItem(LPDRAWITEMSTRUCTlpDrawItem){CDCmyDC;myDC.Attach(lpDrawItem->hDC);//Domorestuffhere//Ifyoudon'tdetach,itwillgetdeletedandwindowswill//notbehappyifyoudeleteit'sdc..myDC.Detach();}
AnotherapproachistocalltheCDCFromHandlemethod:
CDC*pDC=CDC:FromHandle(lpDrawItem->hDC);
It'snotclearwhichis'better',FromHandle()islesserrorpronebecauseyoudonothavetorememberto'detach'.
[email protected](JimMcCabe)6/5/95
5.2.CBitmap
5.2.1.HowdoIreada256colorbitmapfilefromdisk?
Currently,MFCdoesnotcontaindirectsupportforreadinganddisplayingDIBsorBMPs.However,thereareanumberofsampleapplicationsthatillustratejusthowtodothis.
ThefirstsampleistheMFCsampleapplicationDIBLOOK.TheMULTDOCSsampleusesthesamesourcecodeprovidedbyDIBLOOKtoreadanddisplayDIBsandBMPs.
TwootherexamplesprovidedwithVisualC++aretheSDKsamplesDIBVIEWandSHOWDIB.
Questionpostedoncomp.lang.c++,6/5/95,foundthisinMSFAQ,6/25/95
6.Windows,Controls,andDialogClassQuestions
6.1.Windows6.1.1.HowcanIuseacustomiconforawindow?6.1.2.HowdoIchangethestylesforawindowthat'screatedbyMFC?6.1.3.HowdoIgettheminimalsizeofawindowusingMFC?6.1.4.HowdoIchangeaWindow'stitle?6.1.5.HowdoIgetridof'Untitled'inmymainwindowcaption?6.1.6.HowdoImaximizemyMDIchild?6.1.7.WhydoesfocusgonutsowithaCSplitterWnd?6.1.8.HowdoImakemyfirstMDIchildwindowstartoutmaximized?6.1.9.HowdoImakeawindowstayontopoftheothers?6.1.10.HowdoImakeawindowmoveinfrontofanother?
6.1.11.HowdoIimplementdockingwindowslikeDevStudiohas?NEW!!6.1.12.WhyistheGetSafeHwnd()functionneeded,whenwouldaHWNDmaybeunsafe?
6.2.CSplitterWnd
UPD!!6.2.1.HowdoIcreatenon-resizable(staticANDfixed)splitterbars?
6.3.Controls6.3.1.HowdoIgetaCControlfromaDialogTemplate?6.3.2.HowdoIsubclassacontrolusingMFC?6.3.3.WhydoIgetanASSERTwhenIsubclassacontrol?6.3.4.HowdoIvalidatethecontentsofacontrolwhenitlosesfocus?6.3.5.HowdoIenable/disableabankofcheckboxes?6.3.6.HowdoIchangethebackgroundcolorofacontrol?6.3.7.HowdoItrapthekeyformycontrol?6.3.8.HowcanIDDXwithamultipleselectionlistbox?6.3.9.HowdoIchangethebackgroundcolorofaBUTTON???6.3.10.Whyisn'tCEditputtingthingsonseparatelines?
6.3.11.HowdoIgettotheCEditinacombobox?
UPD!!6.3.12.HowdoIloadmorethan64Kintoaneditcontrol?6.3.13.HowdoIsubclassthelistboxportionofacombobox?6.3.14.HowdoIinheritafromaMFCstandardcontrolclass?
NEW!!6.3.15.HowdoyouaddcontrolstoaCDialogdynamically,insteadofusingadialogresource?NEW!!6.3.16.Whyismyfixed-heightownerdrawnlistbox'sMeasureItemnevercalled?6.4.WindowsCommonControls(A.K.A.Windows95Controls)
6.4.1.CanIusethesecontrolsunderNTorWin32s?6.4.2.Where'sademoofthesewickedlycoolcontrols?6.4.3.HowdoyouhandleNM_DBLCLKforaCListCtl?6.4.4.DoesCTreeCtrlsupportmultipleselection?6.4.5.WhenIexpandanodeinmyCTreeCtrl,there'snovisualfeedback,whattodo?6.4.6.HowdoIgetmultipleselection,tooltips,editablenodes,multiplecolumnsinmytrees?
NEW!!6.4.7.HowdoItellaCListCtrlobjecttoselectthewholelineandnotjusttheleftcolumn,whenyouclickonanitem?NEW!!6.4.8.HowdoyouturnofftheslidinganimationthathappenswhenaTreeCtrlisexpandedorcollapsed?NEW!!6.4.9.Whenimplementingdrag/dropoperations,howdoyougetthedifferentcursors:copy,shortcut,circlewiththeslash,etc.?
6.5.Dialogs6.5.1.HowdoIcentermydialog?6.5.2.HowdoIgetthe'oldstyle'commondialogsonwin95?
UPD!!6.5.3.HowdoIsubclassawin95commondialog?6.5.4.CDialog::Create()fails,whatcouldbewrong?6.5.5.HowdoIcreateatoolbar/statusbarinadialog?6.5.6.Whyisn'tmyCDialog::PreCreateWindow()gettingcalled?6.5.7.HowdoIembedacommondialoginapropertypage?6.5.8.Whycan'tIDDX/DDVtoinitializemyCDialogcontrols?6.5.9.HowdoIchangethecaptionsofaCPropertyPage?6.5.10.HowdoItrapF1inmydialog?6.5.11.HowdoIchangetheiconforadialog-onlyMFCapplication?
NEW!!6.5.12.HowtoIgetridoftheHelpandApplybuttonsonmyCPropertySheet-derivative?NEW!!6.5.13.Howdoyouaddaresize'handle'toadialog?
6.1.Windows
6.1.1.HowcanIuseacustomiconforawindow?
TheMicrosoftFoundationClassLibrarystoresiconsforthemainframewindowandtheMDIframewindowasresources.TheiconwithresourceIDAFX_IDI_STD_MDIFRAMEistheiconfortheMDIframewindow,andtheiconwithresourceIDAFX_IDI_STD_FRAMEistheiconforthemainframewindow.Toreplacetheseiconsinyourapplication,addanicontoyourresourcesfilewiththeappropriateID.
TheapplicationspecifiestheiconforaviewinanMDIchildwindowwhenitcreatesthetemplate.TheapplicationusestheiconwiththespecifiedresourceIDwhentheuserminimizestheMDIchildwindowthatcontainsthecorrespondingview.
Thistechniqueallowsyoutospecifyoneiconfortheapplicationtoassociatewiththesewindows.Windowsalsosupportsdynamicallypaintingaminimizedwindow.TodothiswithMFC,useAfxRegisterWndClass()toregisterawindowclasswithaNULLiconhandle.OverridethePreCreateWindow()functioninthewindowclassforthedynamicallypaintediconandcopythenamereturnedbyAfxRegisterWndClass()intothelpszClassNamememberoftheCREATESTRUCT.ThiscreatesthewindowusingtheclassthathasaNULLicon.Whentheuserminimizesthiswindow,theiconreceivesWM_PAINTmessagesthatitcanprocesstodisplayinformationappropriately.Todoso,overridetheOnPaint()messagehandlerandcalltheIsIconic()functiontoseeifthewindowisminimized.Ifso,createaCPaintDCobjectanduseittodrawontheicon.Ifthewindowisnotminimized,callthebaseclassversionofOnPaint()toupdatethewindownormally.
MSVCKnowledgeBase6/4/94
6.1.2.HowdoIchangethestylesforawindowthat'screatedbyMFC?
Tochangethedefaultwindowattributesusedbyaframeworkapplication
createdinAppWizard,overridethewindow'sPreCreateWindow()virtualmemberfunction.PreCreateWindow()allowsanapplicationtoaccessthecreationprocessnormallyprocessedinternallybytheCDocTemplateclass.TheframeworkcallsPreCreateWindow()justpriortocreatingthewindow.BymodifyingtheCREATESTRUCTstructureparametertoPreCreateWindow(),yourapplicationcanchangetheattributesusedtocreatethewindow.
TheCTRLBARSsampleapplication,providedwiththeMicrosoftFoundationClassLibraryversion2.0,demonstratesthistechniquetochangewindowattributes.NotethatdependingonwhatyourapplicationchangesinPreCreateWindow(),itmaybenecessarytocallthebaseclassimplementation.Formoreinformation,seeMSVCknowledgebasearticleQ99847.
MSVCKnowledgeBase6/7/95
6.1.3.HowdoIgettheminimalsizeofawindowusingMFC?
WriteahandlerforWM_GETMINMAXINFO.
[email protected],MikeBlaszczak,6/12/95viaprogrammer.misc
6.1.4.HowdoIchangeaWindow'stitle?
AfxGetApp()->m_pMainWnd->SetWindowText("MyWindowTitle");
-or-AfxGetMainWnd()->SetWindowText("MyOwnTitle");
[email protected],mfc-l,7/9/95
6.1.5.HowdoIgetridof'Untitled'inmymainwindowcaption?
OverridethePreCreateWindow()functioninyourMainFrameclassanddothefollowinginit..
cs.style&=~FWS_ADDTOTITLE;
Youcanalsosettheinitialwindowposition(cs.x,cs.y,cs.cx,cs.cy)thiswayandchangeyourclass(cs.lpszClass)thisway!RemembertocallCFrameWnd::PreCreateWindowattheend...
[email protected],programmer.misc,7/29/95
6.1.6.HowdoImaximizemyMDIchild?
voidCMainFrame::ActivateFrame(intnCmdShow){if(!m_bActivated){m_bActivated=TRUE;nCmdShow=SW_SHOWMAXIMIZED;}CFrameWnd::ActivateFrame(nCmdShow);}
wherem_bActivatedisamembervariableofyourframeobject.
[email protected],programmer.win32,8/3/95
6.1.7.WhydoesfocusgonutsowithaCSplitterWnd?
WheneverImovethesplitterbar,theI-beamcursorinmyeditcontrolgoesaway.Ihavetoclickagainintheeditcontroltogetbackthecursor.
ThefollowingKnowledgeBaseArticle(GOMSKBonCIS)explainsthefocusproblemassociatedwithsplitterwindowsandacoupleofwork-aroundstotheproblem.Thismaybeofhelptoyou.
ID:Q108434
FIX:CSplitterWndClassDoesNotHandleAllFocusCases
Ramesh,NetQuest.,MSMFC,8/3/95
6.1.8.HowdoImakemyfirstMDIchildwindowstartoutmaximized?
Hereisasolutionwhichworksforme:
classCChildFrame:publicCMDIChildWnd{//..stuffdeleted...//ThismakestheMDIchildmaximized.
virtualvoidActivateFrame(intnCmdShow){//ifanotherwindowisopen,usedefaultif(GetMDIFrame()->MDIGetActive())CMDIChildWnd::ActivateFrame(nCmdShow);else//elseopenmaximized.CMDIChildWnd::ActivateFrame(SW_SHOWMAXIMIZED);}//...stuffdeleted...};
-StephenBade,[email protected]
6.1.9.HowdoImakeawindowstayontopoftheothers?
SetWindowPos(&wndTopMost,NULL,NULL,NULL,NULL,SWP_NOMOVE|SWP_NOSIZE)
(likeDBWINdoes)
[email protected],viamfc-l,1/19/95
6.1.10.HowdoImakeawindowmoveinfrontofanother?
Calleither:
SetWindowPos(&wndTop,NULL,NULL,NULL,NULL,SWP_NOMOVE|SWP_NOSIZE)
Or
BringWindowToFront();
[email protected],viamfc-l,1/19/95
6.1.11.HowdoIimplementdockingwindowslikeDevStudiohas?
MFCdoesnoteasilyletyoudothis.Theproblemisthatthedockbar/controlbararchitectureisbuiltforbasictoolbars,notwindows.WehavesolvedtheprobleminourObjectiveToolkitproduct-http://www.stingray.comhasdemosandwhitepapers-checkitout!
NEW!!6.1.12.WhyistheGetSafeHwnd()functionneeded,when
mailto:[email protected]://www.stingray.com/
wouldaHWNDmaybeunsafe?
IfyouseetheMFCsourcecodeinafxwin2.inlinmsdev\mfc\includedirectory,youwillrealizewhyyouneedGetSafeHwnd()function.It'simplementationgoessomethinglikethis:
_AFXWIN_INLINEHWNDCWnd::GetSafeHwnd()const{returnthis==NULL?NULL:m_hWnd;}
whichdoesnothingotherthancheckingforaCWndpointerandifitisnotnullreturningthem_hWndmembervariableofit.ThereisapossibilityofCWndisnullandm_hWndisjunksoGetSafeHwnd()isarealusefulfunction.Itdoesthecheckingforyouaboutwindowpointers,whicharethepartofWindowsPtrToHandlemaps.Justcheckabouthandlemapswhicharepermanentandtemporaryandthenyouwillrealizetheimportanceofthatfunction.
ChandraSekharRentachinthala,[email protected],mfc-l,6/28/98
mailto:[email protected]
6.2.CSplitterWndFAQs
%%TODO-addlotsofthese,emailusyourtoughestones.
FYI-MFCInternalshasawholechapterdevotedtothis-it'smypersonalfavoriteMFCclassbecauseithaslotsofinterestinginternals,shortcomings,oddbehaviors,etc..
WewroteaDDJarticlewhereweshowhowtoswapthesplitterfromhorizontaltovertical.Ithinkthecodeisathttp://www.ddj.comifyouareinterested.
UPD!!6.2.1.HowdoIcreatenon-resizable(staticANDfixed)splitterbars?
SeeKBarticleQ105150"PreventingStaticSplittersfromTracking".Itdescribeshowtodothis.Basically,deriveaclassfromtheCSplitterWndandoverridetheleftbuttonandmousemovemessages:calltheCWndversionsratherthanCSplitterWndversions.Finally,removemenuitemsthatmaygenerateID_WINDOW_SPLITcommands.
[email protected],viamfc-l9/28/95
Toaddtotheaboveanswer,youshouldalsohandletheWM_SETCURSORmessageandjustcalltheCWndversionsothatthehorizontalandverticalresizepointersarenotshown.
BOOLCMySplitterWnd::OnSetCursor(CWnd*pWnd,UINTnHitTest,UINTmessage){returnCWnd::OnSetCursor(pWnd,nHitTest,message);}
MichaelPickens,[email protected]
http://www.stingray.com/mfc_internals/http://www.ddj.com/mailto:[email protected]:[email protected]:[email protected]
6.3.Controls
6.3.1.HowdoIgetaCControlfromaDialogTemplate?
YoucangetapointertoacontrolfromaalreadycreateddialogcontrolbydoingasimpletypecastoftheresultsfromGetDlgItem.Here'sanexamplethatcreatesaCButtonfromacheckboxwithID:IDC_CHECK1.
voidmy_function(CDialog*pDialog){CButton*pButton=(CButton*)pDialog->GetDlgItem(IDC_CHECK1);ASSERT(pButton!=NULL);pButton->SetCheck(m_bShowState);}
Notethatit'salwayssafertocheckforthevalidityoftheresultsfromGetDlgItem.
[email protected],6/1/95
6.3.2.HowdoIsubclassacontrolusingMFC?
ReadthedocumentationonSubClassDlgItem.Here'sanexampleofhowtocallit:
BOOLCMyDialog::OnInitDialog(){//Doyoursubclassingfirst.m_MyControl.SubClassDlgItem(ID_MYCONTROL,this);//Letthebaseclassdoitsthing.CDialog::OnInitDialog();//Perhapsdosomemorestuff//BesuretocallCtl3dlast,oritwillcause//assertionsfrommultiplesubclassing.Ctl3dSubclassDlg(m_hWnd,CTL3D_ALL);}
MikeWilliams,[email protected],mfc-l6/1/95
6.3.3.WhydoIgetanASSERTwhenIsubclassacontrol?
MakesurethatyousubclassthecontrolBEFOREyoucallCtl3dSubclassDlg,ifthe3-dcontrolDLLisloadedfirst,itwillalreadyhavesubclassedyourcontrolsandyouwillgetanassert.
MikeWilliams,[email protected],mfc-l6/1/95
6.3.4.HowdoIvalidatethecontentsofacontrolwhenitlosesfocus?
NOTE:ThisisintheMicrosoftSoftwareLibrary.
TheFCSVALsampleapplicationwascreatedtoshowhowanapplicationcandocontrol-by-controlvalidationinadialogbox.
TheapplicationitselfisjustamodaldialogboxdisplayedbytheCWinApp::InitInstance().Afterdisplayingthedialogbox,InitInstance()simplyquitstheapplication.
Theimportantpartofthesampletakesplaceinthedialog-boxclassimplementation:Therearetwoeditcontrols.Thefirsttakesinputofanintegerbetween1and20.Thesecondtakesacharacterstringasinputwithlengthlessthanorequalto5.WhenyouTabormouse-clickfromcontroltocontrolwithinthedisplayeddialogbox,thecontentsofthecontrolthatislosingfocusarevalidated.
TheCFocusDlgClass
Theapplication'sfunctionalitycentersaroundtheCFocusDlgclassanditsimplementationoffourmessagehandlers(discussedbelow).Normaldataexchange(DDX)andvalidation(DDV)usingtheroutinesprovidedbyMFCtakeplaceinOnInitialUpdate(),whenthedialogboxisfirstdisplayed,andwhentheuserchoosestheOKbuttontoaccepttheinput.ThisisdefaultbehaviorprovidedbyClassWizardwhenmembervariablesareconnectedtodialog-boxcontrolsandcanbeexaminedinthedialogclassDoDataExchange()function.
ValidatingcontrolcontentswhenswitchingfocusfromonecontroltothenextisdonebyhandlingtheEN_KILLFOCUSnotificationsentbytheeditcontrolthat
islosingfocus.Theideahereistocheckthecontentsand,iftheyarenotvalid,todisplaythemessagebox,informtheuser,andthensetthefocusbacktothecontrolfromwhichitcame.Unfortunately,somedifficultiesarisewhentryingtosetthefocus(ordisplaythemessageboxes)withinakillfocusmessagehandler.Atthispoint,Windowsisinanindeterminatestateasitismovingfocusfromonecontroltotheother.ThisisabadplacetodothevalidationandSetFocus()call.
Thesolutionhereistopostauser-definedmessagetothedialogbox(parent)anddothevalidationandSetFocus()there,thuswaitingforasafertimetodothework.(See"CFocusDlg::OnEditLostFocus()"inthefileFOCUSDLG.CPPand"WM_EDITLOSTFOCUSuser-definedmessage"inthefileFOCUSDLG.H.)AnotherthingyouwillnoticeaboutthisfunctionisthatitusesTRY/CATCHtodothevalidation.TheprovidedDDX/DDVroutinesthrowCUserExceptionswhenfailingtovalidateorloadacontrol'sdata.YoushouldcatchtheseanddotheSetFocus()intheCATCHblock.
Note:Thissamplehasothercoolstuff,butthisisthemajoroneI'veseenaskedaboutontheNet.
MSFAQ,6/25/95
6.3.5.HowdoIenable/disableabankofcheckboxes?
Idon'tknowaboutamagicwaytodothisusingasingleHWND,butthereisasimpleandself-documentingtechniquethatI'vebeenusingforalongtime.YoucanmakearoutinethatacceptsanarrayofUINTs(yourcontrolIDs)andavisibilityflag.Thisfunctioncanbeastand-alonefunction,oryoucanputitinsideaclass.IhavebeencollectinglittleutilityfunctionslikethisandkeeptheminaCDialogBaseclass--whenIcreateanewdialogboxinClassWizard,IfixupthecodetoderivefromCDialogBaseinsteadofCDialog.
Forexample,thefunctionmightlooklikethis:
voidCDialogBase::ShowControls(UINT*pControls,UINTcControls,BOOLfVisible){for(UINTuIndex=0;uIndex<cControls;uIndex++){CWnd*pwnd=GetDlgItem(pControls[uIndex]);if(pwnd){
pwnd->ShowWindow(fVisible?SW_SHOW:SW_HIDE);pwnd->EnableWindow(fVisible);}}}
Thenlater,ofteninyourOnInitDialoghandler,youcancallthisfunctionwithyourcontrolgroup:
#defineSIZEOF_ARRAY(a)(sizeof(a)/sizeof(a[0])){staticUINTaGroup1[]={DLG_CHBOX1,DLG_CHBOX2,DLG_STATIC1};staticUINTaGroup2[]={DLG_LABEL2,DLG_LABEL7};ShowControls(aGroup1,SIZEOF_ARRAY(aGroup1),TRUE);ShowControls(aGroup2,SIZEOF_ARRAY(aGroup2),FALSE);}
Youcanfindmanyusesforthesecontrolarrayslatertoo...(Changingfontsinaseriesofcontrols,etc...)Goodluck,
[email protected],mfc-l,7/18/95
6.3.6.HowdoIchangethebackgroundcolorofacontrol?
YourdialogcantraptheWM_CTLCOLORmessage,lookuptheMFChelpfilenotesforCWnd::OnCtlColor().Beforeacontrolisabouttopaintitself,theparentwindowreceivesachancetosetitsowndefaulttextcolorandbackgroundbrush.
[email protected],mfc-l,7/18/95
AlsocheckouttheMSKBarticleID:Q117778TITLE:ChangingtheBackgroundColorofanMFCEditControl.
Ramesh,MSMFC,7/19/95
6.3.7.HowdoItrapthekeyformycontrol?
HandleWM_GETDLGCODEandreturntheappropriatevalue.Rememberthatthelistbox(oranyothercontrol)canonlyhandlekeyboardinputwhenithasthefocus.
[email protected],programmer.misc,8/21/95,programmer.misc
6.3.8.HowcanIDDXwithamultipleselectionlistbox?
DownloadMLBDDX.ZIPfromtheMSMFClibraryonCIS.You'llgetallthenecessarycode.Whenthedialogcloses,aprovidedCStringListwillbefilledwiththeselecteditems.Freeware.
-PatrickPhilippot,CISemail,8/3/95
6.3.9.HowdoIchangethebackgroundcolorofaBUTTON???
NOTE:THEMETHODIN6.3.6WILLNOTWORKFORBUTTONS!
Ifyouwanttochangethecolorofadialogbutton,youhavetouseowner-drawbutton.(youcanusebitmapbuttons)ChangingthecolorthroughOnCtlColor()willnotworkforbuttons.ThefollowingKnowledgeBasearticles(GOMSKBonCIS)maybeofhelptoyou.
ID:Q32685TITLE:UsingtheWM_CTLCOLORMessage
ID:Q64328SAMPLE:Owner-Draw:3-DPushButtonMadefromBitmapswithText
Thisarticleexplainssamplecodeforaowner-drawbutton.
Ramesh,NetQuest.,MSMFC,8/3/95
6.3.10.Whyisn'tCEditputtingthingsonseparatelines?
Makesurethatthelinesareseparatedwith\r\n,notjust\n.
[email protected],mfc-l,8/7/95
6.3.11.HowdoIgettotheCEditinacombobox?
CComboCoxcombo;CEditedit;//comboboxcreation...//...POINTtmpPoint={1,1};edit.SubclassWindow(combo.ChildWindowFromPoint(tmpPoint)->GetSafeHwnd());
[email protected],mfc-l,8/25/95
Or:
Lookintothemfcsample-npp-npview.cpp!Turnsoutallcombo'screatetheireditswithanIDof1001(decimal)so-ifpComboBoxisthepWndobjectpointingtothecombo-allyouneedis:
pComboBox->GetDlgItem(1001);
UPD!!6.3.12.HowdoIloadmorethan64Kintoaneditcontrol?
TheRichEditControlavailableinVC++2.1+supportsmuchmorethan64k.TheWordpadsampleisagreatwaytolearnmoreaboutthissubject.Ifyou'restuckwith16-bitprogramming,Ithinkthatmagmasystemshasa16-bitDLLthatdoesthis.ContactMarcAdlerat:[email protected].
IhavefoundunderNTthatunlessyouuseSetLimitText(0)(orsendaEM_SETLIMITTEXTwithWPARAM=0)youarelimitedtoaddingabout32Kprogramatically.YoudontgetanywarningorEN_ERRSPACE;youjustloosetheendoftextyouadd.
StephenLee[[email protected]]
6.3.13.HowdoIsubclassthelistboxportionofacombobox?
ThelistboxportionofacomboboxisoftypeCOMBOLBOX(noticethe'L').BecausetheComboLBoxwindowisnotachildoftheComboBoxwindow,itisnotobvioushowtosubclasstheCOMBOLBOXcontrol.Luckily,undertheWin32API,WindowssendsamessagetotheCOMBOBOX(noticeno'L')calledWM_CTLCOLORLISTBOXbeforethelistboxisdrawn.ThelParampassedwiththismessagecontainsthehandleofthelistbox.Forexample:
LRESULTCFileUpdateCombo::OnCtlColorListBox(WPARAMwParam,LPARAMlParam){if(!m_bSubclassedListBox){HWNDhWnd=(HWND)lParam;CWnd*pWnd=FromHandle(hWnd);
if(pWnd&&pWnd!=this){//m_ListBoxisderivedfromCListBoxm_ListBox.SubclassWindow(hWnd);m_ListBox.SetOwner(this);m_bSubclassedListBox=TRUE;}}return(LRESULT)GetStockObject(WHITE_BRUSH);}
[email protected],email,9/7/95
6.3.14.HowdoIinheritfromaMFCstandardcontrolclassandprovideinitializationcodethatworksonbothsubclassedandnon-subclassedcontrols?
[ednote:Ok,thisprobablyisn'taFAQ,butIthoughtitsoundedprettycool.]
Ihaveafix,butyoumaynotlikeit;however,ittakescareofbothsubclassingmethods.
IfSubclassWindow()wasvirtual,allproblemswouldbesolved,asSubclassDlgItemcallsSubclassWindow(),andcommoninitializationcouldbecalledfromthispoint,andfromOnCreate().EvenbetterwouldbeavirtualSetupWindow()functioncalledfromallinitializationpointsbyMicrosoft'scode.
C'estlavie.Myfixmightslowthemessageloopforthecontrolinquestion,butsofarIhaven'tseenanyperformancehits.Over-ridethevirtualfunctionWindowProc()foryourcontrolsomethinglikethefollowing(callSetupWindow()inOnCreate()also):
LRESULTCExtendControl::WindowProc(UINTmessage,WPARAMwParam,LPARAMlParam){if(!m_bSetup)SetupWindow();returnCEdit::WindowProc(message,wParam,lParam);}//Thisisavirtualfunction.UseitforHwndsetupinallinherited//classes.Itwillworkforasubclassedwindow.voidCExtendControl::SetupWindow(){ASSERT(m_hWnd);m_bSetup=TRUE;
//***InsertInitializationCodehere!***}
JodyPower([email protected])
NEW!!6.3.15.HowdoyouaddcontrolstoaCDialogdynamically,insteadofusingadialogresource?
YoucanaddcontrolstoyourdialogdynamicallybyusingmethodsCWnd::Create()andCWnd::CreateEx()oroverridablesofCWnd::Create()incontrolwindowwrapperclassessuchasCEditorCListbox,etc.Forexample,tocreateCEditcontrol,youcandothefollowing:
1)addamembervariablem_ec_myedittoyourdialog.hfile;
2)IassumethatyourdialogtempletehassomecontrolwithID=IDC_ABOVE_DYNAMIC_EDIT,andyouwantyourdynamicallycreatededitcontroltohavethesamewidthandbeplacedunderIDC_ABOVE_DYNAMIC_EDIT.ThenaddthefollowingcodeunderthecalltoCDialog::OnInitDialog()inyouroverridenOnInitDialog():
GetDlgItem(IDC_ABOVE_DYNAMIC_EDIT)->GetWindowRect(rect);ScreenToClient(rect);CRectrectNew(rect.left,rect.bottom+5,rect.right,rect.bottom+35);m_myEdit.CreateEx(WS_EX_CLIENTEDGE,"EDIT",NULL/*lpszWindowName*/,WS_CHILD|WS_VISIBLE|WS_GROUP|WS_TABSTOP|WS_BORDER,rectNew.left,rectNew.top,rectNew.Width(),rectNew.Height(),this->GetSafeHwnd(),NULL,NULL);m_myEdit.ShowWindow(SW_SHOW);
It'sthatsimple.Theonlythingthatdiffersfordifferentcontrolclassesiswindowstyles.Usually,youcanfindthemostimportantofstyleandextendedstyleconstantsinonlinehelp.
[email protected],mfc-l,6/12/98
NEW!!6.3.16.Whyismyfixed-heightownerdrawnlistbox'sMeasureItemnevercalled?
TheMeasureItemfunctionforafixed-heightownerdrawnisonlycalledonce.TheproblemisthatitiscalledbeforetheMFClistboxobjectisassociatedwith
mailto:([email protected]:[email protected]
theWindowslistboxcontrol.Thesolutionistoinvokethelistbox'sMeasureItemfromtheOnMeasureItemfunctionofthedialogcontainingthelistbox:
voidCExampleDlg::OnMeasureItem(intnIDCtl,LPMEASUREITEMSTRUCTlpMeasureItemStruct)
{CDialog::OnMeasureItem(nIDCtl,lpMeasureItemStruct);if(nIDCtl==IDC_LISTBOX)m_ListBox.MeasureItem(lpMeasureItemStruct);}
EricBergman-Terrell,[email protected],5/16/97
mailto:[email protected]
6.4.WindowsCommonControls(a.k.a.Windows95controls)
6.4.1.CanIusethesecontrolsunderNTorWin32s?
WindowsNT3.50doesnotsupportthecommoncontrols,andwillnotinthefuture.YoumustuseWindowsNTversion3.51togainthecommoncontrols.
[email protected],mfc-l,7/6/95
Version1.30ofWin32ssupportstheCommoncontrols.
6.4.2.Where'sademoofthesewickedlycoolcontrols?
CheckouttheMFCsample,fire,itfeaturesmostofthecontrolsinaction:MSVC20\samples\mfc\fire.Under4.0,there'sanotheronecalledcmnctrls.
[email protected],7/27/95
6.4.3.HowdoyouhandleNM_DBLCLKforaCListCtl?
BEGIN_MESSAGE_MAP(CListView,CView)ON_NOTIFY(NM_DBLCLK,ID_LISTCTRL,OnDblClick)END_MESSAGE_MAP()
voidCListView::OnDblClick(NMHDR*/*k*/,LRESULT*/*j*/){intnItem,nFlags;charszTest[80];nFlags=LVNI_SELECTED;nItem=m_ListCtrl->GetNextItem(-1,nFlags);if(nItem!=-1){sprintf(szTest,"SelectedItem%d",nItem);AfxMessageBox(szTest);}}
[email protected],mfc-l,7/21/95
6.4.4.DoesCTreeCtrlsupportmultipleselection?
No.Sorry!(Iseethisoneallthetime!)
Ifit'saccessibletoyou,MicrosoftSystemsJournal,July1994,hasanextensivelookatTreeViews,includingasampleprogramthatincludesdrag&drop.Ifyou'redevelopingforWindows95,youdon'tneedasharewareimplementation,MFChasaclassforit.
6.4.5.WhenIexpandanodeinmyCTreeCtrl,there'snovisualfeedback,whattodo?
CreatethecontrolwithTVS_SHOWSELALWAYSstyle.
6.4.6.(TheFAQofthedevil!)HowdoIimplementmultipleselection,tooltips,editablenodesandmultiplecolumnsinmytreecontrol?
Unfortunately,sincethetreecontrollivesinabinaryDLL,itisnotveryextensibleandyouarestuckwithoutthesefeatures.Therehavebeenarticlesonhowtotryand"hack"thesefeatures,buttheydonotworkreliably.
Wehaveadrop-intreecontrolreplacementthatimplementsallofthesefeaturesandmoreinObjectiveToolkit.Demosareathttp://www.stingray.com.
NEW!!6.4.7.HowdoItellaCListCtrlobjecttoselectthewholelineandnotjusttheleftcolumn,whenyouclickonanitem?
TheeasiestwayofgettingfullrowselectisifyouusetheupdatedcommoncontrolsDLL(versions>=4.70)suppliedwithIE.WiththatyoucanusetheLVM_SETEXTENDEDLISTVIEWSTYLEmessagetosettheLVS_EX_FULLROWSELECTstyle.
http://www.stingray.com/
mfc-l,6/21/98
NEW!!6.4.8.HowdoyouturnofftheslidinganimationthathappenswhenaTreeCtrlisexpandedorcollapsed?
IhaveusedLockWindowUpdate()andUnlockWindowUpdate()inthepasttoachievewhatyouareaskingusingaCListCtrl.ThefunctionsareinCWndandsinceCTreeCtrlisderivedfromCWndthisshouldworkthesame.
TedDasler[[email protected]],mfc-l,6/19/98
NEW!!6.4.9.Whenimplementingdrag/dropoperations,howdoyougetthedifferentcursors:copy,shortcut,circlewiththeslash,etc.?
IbelieveyouwanttooverridetheOnDragEnter()andOnDragOver()methods.ReturningDROPEFFECT_NONEwillgiveyouthecirclewithaslash.DROPEFFECT_LINKwillgiveyouthearrow.DROPEFFECT_COPYwillgiveyoutheplussign.
CaryWalker[[email protected]],VCPPmailinglist,6/29/98
6.5.Dialogs
6.5.1.HowdoIcentermydialog?
UsetheCWnd::CenterWindowmethodaccomplishthis.IusuallyputitinmyOnInitDialogoverloadedfunction.SinceCDialogisanancestorofCWnd,youcancallthemethoddirectly:
BOOLCMyDialog::OnInitDialog(){//Performanyotherdialoginitializationuphere.CenterWindow();returnTRUE;}
[email protected],6/1/95.
6.5.2.HowdoIgetthe'oldstyle'commondialogsonwin95?
MFCdetectsifitisrunningonWin95,andifso,replacesthestandardFileOpenDialogwithanexplorerversionoftheFileOpenDialog.YoucanpreventMFCfromusingthis"explorer"versionbyaddingthefollowinglinetoyourCFileDialogderivedclassconstructor:
m_ofn.Flags&=~OFN_EXPLORER;
[email protected](AndyDeWolfe),viaprogrammer.win32,5/10/95
UPD!!6.5.3.HowdoIsubclassawin95commondialog?
YoucandoitbutMicrosofthasmadeitmuchmoredifficultinWin95.Youneedtocreatea"childdialogtemplate"(withtheWS_CHILDstyle)andsetittom_ofn.lpTemplateName(makingsurem_ofn.hInstanceissettoyourappinstance).Thistemplatemust*only*containthecontrolsthatyouareaddingtothedialog(ie.NOTthewholedialogwiththestandardcontrolsduplicatedasinWin3.x).
Whenthedialogisinvoked,yourtemplatewillappear(bydefault)belowtheregularfiledialogcontrols.Ifyouputastaticcontrolwithidstc32(definedin
include\dlgs.h),thecommondialogcodewillrearrangethingssothattheoriginalcontrolswillappearwhereveryourputthestc32control(youdon'thavetosizeittomatchthecommondlgcodewilldothatforyou).
Youwillneedtosupplym_ofn.lpfnHookandhandleyouradditionalcontrolsthroughthehookproc.NotethatsincethesystemputsyourdialogtemplateONTOPofthenormaldialog,MFCmessageroutingwon'tgettoyourcontrolssoyoucan'tcodethemthroughamessagemapinyourCFileDialogderivative.Ifanybodyhasfoundawayaroundthis,I'dlovetohearit!!
ThisisverymessyandMicrosoftknowsit.TheypromiseafixinMFC4.0.[ed.note:Thisismuchnicerin4.0.Therearevirtualstooverrideforgettingcallbacks,plusitevenhandlestheoldandnewstyletemplates-prettycleverstuff!]
[email protected],JoeJanakovic,viaprogrammer.win32,6/10/95
Thisisactuallyadocumentationbug...Ihaven'tfoundthisinformationelsewhere.Ifyou'resubclassingthecommonfiledialog,andyouwanttoclosethedialogwhentheuserpressesabutton,theentryinMSDNonOFNHookProcsaysthatyoushouldnotuseEndDialog,butthatyoushouldpostaWM_COMMANDmessagetothemaindialog(whichistheparentofyourcustomisingdialog),specifyingIDABORTasthecontrolID.Thisworkswiththeold-style,non-Explorerfiledialog,butnotwiththeExplorer-styledialog.YounowhavetouseIDCANCEL;andthisalsoworkswiththeold-styledialog.
Ifyou'reusingMFC,youcanwritethefollowing:
if(GetParent()!=GetTopLevelParent()){//Explorer-styleGetParent()->PostMessage(WM_COMMAND,MAKEWPARAM(IDCANCEL,BN_CLICKED));}else{//oldstylePostMessage(WM_COMMAND,MAKEWPARAM(IDCANCEL,BN_CLICKED));}
-rickcameron[[email protected]],6/18/98
mailto:[email protected]
6.5.4.CDialog::Create()fails,whatcouldbewrong?
InvalidHWNDpassedasaparentInvaliddialogresourceIDpassed(becarefulaboutnumericIDsvs.stringIDs--becarefulwith#defineID_MYDIALOG0x1234--itisa"string"IDtotheresourcecompiler).Oneormorecontrolsonyourdialogcouldnotbecreated,usuallyBecauseoftheuseofacustomcontrolthatwasnotregistered.CallingEndDialogduringtheOnInitDialogmessage(orsomeotherhandlercalledearlyinthegame)!NULLHWNDpassedasparentwhendialoghasWS_CHILDstyle
That'saboutallIcanthinkofrightnow,
DeanMcCrory,MSMFC,6/16/95
6.5.5.HowdoIcreateatoolbar/statusbarinadialog?
There'sas