欢迎来到天天文库
浏览记录
ID:48061480
大小:128.50 KB
页数:26页
时间:2020-01-13
《Chapter Two Windows Programming and MFC Application Framework.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、C++ProgrammingChaper7WindowsProgrammingandMFCIntroducingIndex7.1TheWindowsProgrammingModel7.1.1MessageProcessing7.1.2Handles7.1.3WindowsAPIs7.1.4AWindowsProgram7.2IntroducingMFC7.2.1TheVisualC++Components7.2.2MFCApplicationFramework7.1TheWindowsProgrammingModelProgramswritte
2、nfortraditionaloperatingenvironmentsuseaproceduralprogrammingmodelinwhichprogramsexecutefromtoptobottominanorderlyfashion.Thepathtakenfromstarttofinishmayvarywitheachinvocationoftheprogramdependingontheinputitreceivesortheconditionsunderwhichitisrun,butthepathremainsfairlypr
3、edictable.InaCprogram,executionbeginswiththefirstlineinthefunctionnamedmainandendswhenmainreturns.Inbetween,mainmightcallotherfunctionsandthesefunctionsmightcallevenmorefunctions,butultimatelyitistheprogram—nottheoperatingsystem—thatdetermineswhatgetscalledandwhen.7.1TheWind
4、owsProgrammingModelWindowsprogramsoperatedifferently.Theyusetheevent-drivenprogrammingmodel,inwhichapplicationsrespondtoeventsbyprocessingmessagessentbytheoperatingsystem.Aneventcouldbeakeystroke,amouseclick,oracommandforawindowtorepaintitself,amongotherthings.7.1TheWindowsP
5、rogrammingModel7.1.1MessageProcessingWheredomessagescomefrom,andwhatkindsofinformationdotheyconvey?Windowsdefineshundredsofdifferentmessagetypes.Mostmessageshavenamesthatbeginwiththeletters"WM"andanunderscore,asinWM_CREATEandWM_PAINT.OnewaytocharacterizeaWindowsprogramistoth
6、inkofitasacollectionofmessagehandlers.Toalargeextent,itisaprogram'suniquewayofrespondingtomessagesthatgivesititspersonality.typedefstructtagMSG{HWNDhwnd;UINTmessage;WPARAMwParam;LPARAMlParam;DWORDtime;POINTpt;}MSG;7.1.1MessageProcessingCommonWindowsMessagesMessageSentWhenWM_
7、CHARAcharacterisinputfromthekeyboard.WM_COMMANDTheuserselectsanitemfromamenu,oracontrolsendsanotificationtoitsparent.WM_CREATEAwindowiscreated.WM_DESTROYAwindowisdestroyed.WM_LBUTTONDOWNTheleftmousebuttonispressed.WM_LBUTTONUPTheleftmousebuttonisreleased.WM_MOUSEMOVEThemouse
8、pointerismoved.WM_PAINTAwindowneedsrepainting.WM_QUITTheapplicationisaboutt
此文档下载收益归作者所有