我的桌面题目电厂燃料管理系统计划模块_第1页
我的桌面题目电厂燃料管理系统计划模块_第2页
我的桌面题目电厂燃料管理系统计划模块_第3页
我的桌面题目电厂燃料管理系统计划模块_第4页
我的桌面题目电厂燃料管理系统计划模块_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

IntroductionofMFCVisualC++ismuchmorethanacompiler.Itisacompleteapplicationdevelopmentenvironmentthat,whenusedasintended,letsyoufullyexploittheobjectorientednatureofC++tocreateprofessionalWindowsapplications.Inordertotakeadvantageofthesefeatures,youneedtounderstandtheC++programminglanguage.IfyouhaveneverusedC++,pleaseturntotheC++tutorialsintheC/C++Tutorialspageforanintroduction.YoumustthenunderstandtheFoundationClass(MFC)hierarchy.ThisclasshierarchyencapsulatestheuserinterfaceportionoftheWindowsAPI,andmakesitsignificantlyeasiertocreateWindowsapplicationsinanobjectorientedway.ThishierarchyisavailableforandcompatiblewithallversionsofWindows.ThecodeyoucreateinMFCisextremelyportable.ThesetutorialsintroducethefundamentalconceptsandvocabularybehindMFCandeventdrivenprogramming.Inthistutorialyouwillenter,compile,andrunasimpleMFCprogramusingVisualC++.2providesadetailedexnationofthecodeusedinTutorial1.Tutorial3discussesMFCcontrolsandtheircustomization.Tutorial4coversmessagemaps,whichletyouhandleeventsinMFC.WhatistheFoundationsClassLet'ssayyouwanttocreateaWindowsapplication.Youmight,forexample,needtocreateaspecializedtextordrawingeditor,oraprogramthatfindsfilesonalargeharddisk,oranapplicationthatletsauservisualizetheinterrelationshipsinabigdataset.Wheredoyoubegin?Agoodstartingceisthedesignoftheuserinterface.First,decidewhattheusershouldbeabletodowiththeprogramandthenpickasetofuserinterfaceobjectsaccordingly.TheWindowsuserinterfacehasanumberofstandardcontrols,suchasbuttons,s,scrollbars,andliststhatarealreadyfamiliartoWindowsusers.Withthisinmind,theprogrammermustchooseasetofcontrolsanddecidehowtheyshouldbearrangedonscreen.Atime-honoredprocedureistomakearoughsketchoftheproposeduserinterface(bytraditiononanapkinorthebackofanenvelope)andywiththeelementsuntiltheyfeelright.Forsmallprojects,orfortheearlyprototyphaseofalargerproject,thisissufficient.alsoprovidesaC++librarythatsitsontopofanyoftheWindowsAPIsandmakestheprogrammer'sjobeasier.CalledtheFoundationClasslibrary(MFC),thislibrary'sprimaryadvantageisefficiency.ItgreatlyreducestheamountofcodethatmustbewrittentocreateaWindowsprogram.ItalsoprovidesalltheadvantagesnormallyfoundinC++programming,suchasinheritanceandencapsulation.MFCisportable,sothat,forexample,codecreatedunderWindows3.1canmovetoWindowsNTor95veryeasily.MFCisthereforethepreferredmethodfordeveloWindowsapplicationsandwillbeusedthroughoutthesetutorials.WhenyouuseMFC,youwritecodethatcreatesthenecessaryuserinterfacecontrolsandcustomizestheirappearance.Youalsowritecodethatrespondswhentheusermanipulatesthesecontrols.Forexample,iftheuserclicksabutton,youwanttohavecodeincethatrespondsappropriay.Itisthissortofevent-handlingcodethatwillformthebulkofanyapplication.Oncetheapplicationrespondscorrectlytoalloftheavailablecontrols,itisfinished.YoucanseefromthisdiscussionthatthecreationofaWindowsprogramisastraightforwardprocesswhenusingMFC.Thegoalofthesetutorialsistofillinthedetailsandtoshowthetechniquesyoucanusetocreateprofessionalapplicationsasquicklyaspossible.TheVisualC++applicationdevelopmentenvironmentisspecificallytunedtoMFC,sobylearningMFCandVisualC++togetheryoucansignificantlyincreaseyourpowerasanapplicationdeveloper.ThevocabularyusedtotalkaboutuserinterfacefeaturesandsoftwaredevelopmentinWindowsisbasicbutunique.Herewereviewafewdefinitionstomakediscussioneasierforthosewhoarenewtotheenvironment.liveinsidea"framewindow".Aframewindowisafullyfeaturedmainwindowthattheusercanre-size,minimize,izetofillthescreen,andsoon.Windowsalsosupportstwotypesofdialogboxes:modalandmodeless.Amodaldialogbox,onceonthescreen,blocksinputtotherestoftheapplicationuntilitisanswered.Amodelessdialogboxcanappearatthesametimeastheapplicationandseemsto"floatabove"ittokeepfrombeingoverlaid.MostsimpleWindowsapplicationsuseaSingle Interface,orSDI,frame.TheClock,PIFeditor,andNotepadareexamplesofSDIapplications.WindowsalsoprovidesanorganizingschemecalledtheMultiple Interface,orMDIformorecomplicatedapplications.TheMDIsystemallowstheusertoviewmultiplesatthesametimewithinasingleinstanceofanapplication.Forexample,atexteditormightallowtheusertoopenmultiplefilessimultaneously.WhenimplementedwithMDI,theapplicationpresentsalargeapplicationwindowthatcanholdmultiplesub-windows,eachcontaininga.Thesinglemain isheldbythemainapplicationwindowanditappliestothetop-mostwindowheldwithintheMDIframe.IndividualwindowscanbeiconifiedorexpandedasdesiredwithintheMDIframe,ortheentireMDIframecanbeminimizedintoasingleicononthedesktop.TheMDIinterfacegivestheimpressionofaseconddesktopoutonthedesktop,anditgoesalongwaytowardsorganizingandremovingwindowclutter.Eachapplicationthatyoucreatewilluseitsownuniquesetofcontrols,itsownstructure,anditsowndialogboxes.Agreatdealoftheeffortthatgoescreatinganygoodapplicationinterfaceliesinthechoiceandorganizationoftheseinterfaceobjects.VisualC++,alongwithitsresourceeditors,makesthecreationandcustomizationoftheseinterfaceobjectsextremelyeasy.Event-drivenSoftwareandVocabularyAllwindow-basedGUIscontainthesamebasicelementsandalloperateinthesameway.Onscreentheuserseesagroupofwindows,eachofwhichcontainscontrols,icons,objectsandsuchthataremanipulatedwiththemouseorthekeyboard.Theinterfaceobjectsseenbytheuserarethesamefromsystemtosystem:pushbuttons,scrollbars,icons,dialogboxes,pulldowns,etc.Theseinterfaceobjectsallworkthesameway,althoughsomehaveminordifferencesintheir"lookandfeel."Forexample,scrollbarslookslightlydifferentasyoumovefromWindowstotheMactoMotif,buttheyalldothesamething.Fromaprogrammer'sstandpoint,thesystemsareallsimilarinconcept,althoughtheydifferradicallyintheirspecifics.TocreateaGUIprogram,theprogrammerfirstputsalloftheneededuserinterfacecontrolsintoawindow.Forexample,iftheprogrammeristryingtocreateasimpleprogramsuchasaFahrenheittoCelsiusconverter,thentheprogrammerselectsuserinterfaceobjectsappropriatetothetaskanddisysthemonscreen.Inthisexample,theprogrammermightlettheuserenteratemperatureinaneditabletextarea,disytheconvertedtemperatureinanotherun-editabletextarea,andlettheuserexittheprogrambyclickingonapush-buttonlabeledAstheusermanipulatestheapplication'scontrols,theprogrammustrespondappropriay.Theresponsesaredeterminedbytheuser'sactionsonthedifferentcontrolsusingthemouseandthekeyboard.Eachuserinterfaceobjectonthescreenwillrespondtoeventsdifferently.Forexample,iftheuserclickstheQuitbutton,thebuttonmustupdatethescreenappropriay,highlightingitselfasnecessary.Thentheprogrammustrespondbyquitting.Normallythebuttonmanagesitsappearanceitself,andtheprograminsomewayreceivesamessagefromthebuttonthatsays,"Thequitbuttonwaspressed.Dosomethingaboutit."Theprogramrespondsbyexiting.Windowsfollowsthissamegeneralpattern.Inatypicalapplicationyouwillcreateamainwindowandceinsideitdifferentuserinterfacecontrols.Thesecontrolsareoftenreferredtoaschildwindows-eachcontrolislikeasmallerandmorespecializedsub-windowinsidethemainapplicationwindow.Astheapplicationprogrammer,youmanipulatethecontrolsbysendingmessagesviafunctioncalls,andtheyrespondtouseractionsbysendingmessagesbacktoyourcode.Ifyouhaveneverdoneany"event-driven"programming,thenallofthismayforeigntoyou.However,theevent-drivenstyleofprogrammingiseasytounderstand.Theexactdetailsdependonthesystemandthelevelatwhichyouareinterfacingwithit,butthebasicconceptsaresimilar.Inanevent-driveninterface,theapplicationpaintsseveral(ormany)userinterfaceobjectssuchasbuttons,textareas,andsontothescreen.Nowtheapplicationwaits-typicallyinapieceofcodecalledaneventloop-fortheusertodosomething.Theusercandoanythingtoanyoftheobjectsonscreenusingeitherthemouseorthekeyboard.Theusermightclickoneofthebuttons,forexample.Themouseclickiscalledanevent.Eventdrivensystemsdefineeventsforuseractionssuchasmouseclicksandkeystrokes,aswellasforsystemactivitiessuchasscreenAtthelowestlevelof ion,youhavetorespondtoeacheventinafairamountofdetail.ThisisthecasewhenyouarewritingnormalCcodedirectlytotheAPI.Insuchascenario,youreceivethemouse-clickeventinsomesortofstructure.Codeinyoureventlooplooksatdifferentfieldsinthestructure,determineswhichuserinterfaceobjectwasaffected,perhapshighlightstheobjectinsomewaytogivetheuservisualfeedback,andthenperformstheappropriateactionforthatobjectandevent.Whentherearemanyobjectsonthescreentheapplication esverylarge.Itcantakequiteabitofcodesimplytofigureoutwhichobjectwasclickedandwhattodoaboutit.Fortunay,youcanworkatamuchhigherlevelof ion.InMFC,almostalltheselow-levelimplementationdetailsarehandledforyou.Ifyouwanttoceauserinterfaceobjectonthescreen,youcreateitwithtwolinesofcode.Iftheuserclicksonabutton,thebuttondoeseverythingneededtoupdateitsappearanceonthescreenandthencallsapre-arrangedfunctioninyourprogram.Thisfunctioncontainsthecodethatimplementstheappropriateactionforthebutton.MFChandlesallthedetailsforyou:Youcreatethebuttonandlitaboutaspecifichandlerfunction,anditcallsyourfunctionwhentheuserpressesit.Tutorial4showsyouhowtohandleeventsusingmessagemaps.Thestepsnecessarytoenterandcompilethisprogramarestraightforward.IfyouhavenotyetinstalledVisualC++onyourmachine,dosonow.Youwillhavetheoptionofcreatingstandardandcustominstallations.Forthepurposesofthesetutorialsastandardinstallationissuitableandafteransweringtwoorthreesimplequestionstherestoftheinstallationisquickandpainless.MFC简要介VisualC++C++Windows应用程序。为了能充分利用这些特性,你必须理解C++C++,你就必须掌握基本类库(MFC)的层次结构。该层次结构包容了WindowsAPI中的用户界面部分,并使你能够很容易地以面向对象的方式建立WindowsWindows用MFC所建立的代码是完全可移植的。这篇文章将向你介绍MFC的基本概念和术语以及驱动程序设计方法。MFC程序。下

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论