资源描述:
《有关Windows编程模式的中英文翻译.doc.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、附录1外文原文[8]TheWindowsProgrammingModelNomatterwhichdevelopmenttoolsyouuse,programmingforWindowsisdifferentfromold-stylebatch-orientedortransaction-orientedprogramming.Togetstarted,youneedtoknowsomeWindowsfundamentals.Asaframeofreference,we'llusethewell-knownMS-DOSprogrammingmodel.Eve
2、nifyoudon'tcurrentlyprogramforplainMS-DOS,you'reprobablyfamiliarwithit.MessageProcessingWhenyouwriteanMS-DOS-basedapplicationinC,theonlyabsoluterequirementisafunctionnamedmain.Theoperatingsystemcallsmainwhentheuserrunstheprogram,andfromthatpointon,youcanuseanyprogrammingstructureyo
3、uwant.Ifyourprogramneedstogetuserkeystrokesorotherwiseuseoperatingsystemservices,itcallsanappropriatefunction,suchasgetchar,orperhapsusesacharacter-basedwindowinglibrary.WhentheWindowsoperatingsystemlaunchesaprogram,itcallstheprogram'sWinMainfunction.Somewhereyourapplicationmusthav
4、eWinMain,whichperformssomespecifictasks.Itsmostimportanttaskiscreatingtheapplication'smainwindow,whichmusthaveitsowncodetoprocessmessagesthatWindowssendsit.AnessentialdifferencebetweenaprogramwrittenforMS-DOSandaprogramwrittenforWindowsisthatanMS-DOS-basedprogramcallstheoperatingsy
5、stemtogetuserinput,butaWindows-basedprogramprocessesuserinputviamessagesfromtheoperatingsystem.NOTEManydevelopmentenvironmentsforWindows,includingMicrosoftVisualC++version6.0withtheMicrosoftFoundationClass(MFC)Libraryversion6.0,simplifyprogrammingbyhidingtheWinMainfunctionandstruct
6、uringthemessage-handlingprocess.WhenyouusetheMFClibrary,youneednotwriteaWinMainfunctionbutitisessentialthatyouunderstandthelinkbetweentheoperatingsystemandyourprograms.MostmessagesinWindowsarestrictlydefinedandapplytoallprograms.Forexample,aWM_CREATEmessageissentwhenawindowisbeingc
7、reated,aWM_LBUTTONDOWNmessageissentwhentheuserpressestheleftmousebutton,aWM_CHARmessageissentwhentheusertypesacharacter,andaWM_CLOSEmessageissentwhentheuserclosesawindow.Allmessageshavetwo32-bitparametersthatconveyinformationsuchascursorcoordinates,keycode,andsoforth.WindowssendsWM
8、_COMMANDmessagestotheappro