visual c++ 畢業(yè)設(shè)計(jì)外文翻譯_第1頁
已閱讀1頁,還剩9頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、<p><b>  附錄 附錄清單A</b></p><p>  Visual C++ MFC concise course</p><p>  MFC introductory remarks</p><p>  Visual C++ not merely is a compiler. It is a comprehensive

2、application procedure development environment,you fully use C++ which has object-oriented characteristic to develop the specialized Windows application procedure. In order to fully use these characteristics, you must und

3、erstand the C++ programming language.If you want grasped C++, you must grasp the Microsoft basic kind of storehouse (MFC) level structure. This level structure contained user contact surface in the Windows API,and enable

4、d</p><p>  If you want establish a Windows application procedure, how should start?</p><p>  The good beginning is from designning user contact surface. First, you must decide what kind of user

5、can use this procedure and according to needs to establish the corresponding user contact surface object. The Windows user contact surface has some standards to control, like the button, the menu, roll the strip and tabu

6、lates and so on, this is be familiared with Windows users. You must remember, as a programmer you mustt choose a group as the programmer to control and to decide how to arranges t</p><p>  The next step, is

7、must realize the code. When for any Windows platform establishment application procedure, the programmers all have two kind of choices: C or C++. Uses C, the programmer is in the Windows application procedure contact sur

8、face (API) in the level compiles the code. This contact surface is composed by several hundred C function, these functions reference manual all have the introduction in Windows in the API. Regarding Windows NT, API is ca

9、lled "Win32 API", distinguishes to it uses</p><p>  Microsoft has also provided the C++ storehouse, it is located above any Windows API, can make programmer's work to be easier. It is the Micro

10、soft basic kind of storehouse (MFC), this storehouse main merit is the high efficiency. It reduce massive codes which established in Windows procedure. Simultaneously it has also provided all general C++ programming meri

11、t. MFC can be transplant, for example, the code which 3.1 compiles in Windows may very easily transplant to Windows NT or Windows 95. There</p><p>  When you uses MFC, you compile the code is uses to establi

12、sh the essential user contact surface to control and to custom-made its outward appearance. Simultaneously you also must compile the codes which use to respond the users’ operation. For example, if the user single-clicks

13、 a button, you should have the code to respond. This is the event actuate code, it constituted all applications procedure. Once the application procedure correct response all permissions control, its duty has also comple

14、te</p><p>  You may see, use MFC to establish Windows programming are a quite easy process. Visual C++ application procedure development procedure environment specially suits to uses MFC (also to have other

15、development environments to use MFC), therefore studies MFC and Visual C++ together can strengthen your development procedure ability.</p><p>  Windows supports several kind of types application procedure wi

16、ndows. A typical application procedure should move in "the frame window" center. A frame window is an entire function main window, the user may change its size, be smallist, be maximum and so on. Windows also s

17、upports two kind of types of dialog boxes: Pattern and non- pattern dialog box. The pattern dialog box once appears on the screen, other parts of the application procedure will respond only when it withdraws. The non- pa

18、ttern d</p><p>  The simplest Windows application procedure is uses the single documents contact surface (SDI), only one frame window. The Windows clock and watch, the PIF editor, the memorandum and so on ar

19、e all examples of the SDI application procedure. Windows also provided multi- documents contact surface form, it might uses in more complex application procedure. The MDI system permission user check many documents in t

20、he same application procedure. For example, a text editor may allow the user open many tex</p><p>  Each procedure you established may use its own control, menu structure as well as the dialog box. To choose

21、 a good application procedure contact surface is decided how to chooses and organizes these contact surface objects. Visual C++ resources editor may enable you easily to establishment and has custom-made these contact su

22、rface objects.</p><p>  Establishment project and translation code</p><p>  In order to translates the code in Visual C++, you must have to establish a project. In order to the such small proced

23、ure to establishes a project it must make a fuss over a trifling matter, but in any actual procedure, the project concept is extremely useful. A project mainly preserving the following three kind of different types infor

24、mation:</p><p>  It may remember all source programs code document which establishes the executive routine. In this simple example, document HELLO.CPP is the only source document, but in a large-scale applic

25、ation procedure, in order to be advantageous for the management and the maintenance, you may be able to have many different sources documents. The project can maintain these different documents tabulating, and necessity

26、translates them when you establish the next executive routine.</p><p>  It can remember uses the compiler and the coupling option in view of yours application procedure. For example, it can remember which st

27、orehouse connected in the executive routine, whether you translated in advance document and so on.</p><p>  It can remember the project type which establishes: A control bench application procedure, or windo

28、w application procedure and so on.</p><p>  If you already understand the project document, then could be very easy to understand the project document function as the machine. Now, we establish a simple proj

29、ect, and translates HELLO.CPP with it.</p><p>  Therefore, first in the menu chooses "New" from "File" the option. In "Projects" in the label, single-clicks "Win32 Applicat

30、ion".Inputs an appropriate way name in "Location" territory or single-clicks "Browse" button to choose.Inputs "hello" in "Project name"as the project name. This time you can s

31、ee "hello" also can appear in "Location" territory. Single-clicks "OK" the button. Visual C++ can newly establish HELLO contents, and put all projects document HELLO.OPT, HELLO.NCB, HELLO.DS

32、P and HELLO</p><p>  Now, in the screen’s left side, appearing three labels. InfoView label still in, also newly appeared ClassView and the FileView label. The ClassView label can list all your procedures, t

33、he FileView label give document tabulating in the project.</p><p>  Now it allowed to input routine code. Chooses "New" in "File" meno to establish an editor window. In appears in dialog

34、box, choose "Files" label and "Text File". Above then can appear Visual C++ intelligent editor, you may use it to input the procedure code. When input code, you can discover the editor can automatical

35、ly turn the different type texts into different colors. If you want change its color or the close color function, you can choose “Options"in "Tools" menu, then chooes "Format" label</p>&l

36、t;p>  After inputs the code, choose "Save" option in"File"menu to preserves. In Visual C++ new establishment ontents, saves it to HELLO.CPP document.</p><p>  Now chooses "Add To

37、Project" option in"Project"menu,and chooses "Files..." . You can see a dialog box for you to chooses the documents which you want to appent. </p><p>  In the screen left side, single

38、-clicks the FileView label, and double-clicks HELLO chart sign. You can see HELLO.CPP document. Single-clicks ClassView label, and double-clicks the folder chart sign, you can see all kinds in procedure. Any time you can

39、 use FileView to delete the project document, you only single-click this document, then click delete key on keyboard.</p><p>  This time you must tell the project to use MFC storehouse. If you neglected this

40、 step, the project in connection time can make a mistake, but mistake information will not give you any help. Choose "Settings"in"Project" menu. In appears dialog box chooses "General" label

41、. In "Microsoft Foundation Classes" Combined frame, choose "Use MFC in a Shared DLL". Then close dialog box.</p><p>  We have already established the project document, and has adjusted th

42、e establishment, you now were allowed to translate the HELLO. CPP procedure. In "Build" menu, you can discover three different translations options:</p><p>  Compile HELLO.CPP (Only when includes H

43、ELLO.CPP window in active way)</p><p>  Build HELLO.EXE </p><p>  Rebuild All</p><p>  The first option only translates the source document and forms their goal document. This optio

44、n cannot complete the connection task, therefore it only useful to fast translates some source documents to inspect right or wrong. The second option translation source documents since last time revised, and connect to m

45、ake the execution file. The third option must retranslate and the connection all sources document.</p><p>  We may choose "Build HELLO.EXE" to translate and the connection code. Visual C++ can esta

46、blish "Debug" new sub-directory, and puts HELLO.EXE in this contents. This sub-directory documents can all reproduce, therefore you may wilfully delete them.</p><p>  If you discovered the translat

47、ion mistakes, double-clicks the error message in the output window. By now the editor could bring you to the position which made a mistake. Inspects your code whether has the question, if has, revises it. If you see the

48、massive connections mistake, then is possible make a wrong project type which assigns in the establishment project dialog box. You may delet the sub-directory of the project,then establishes it again according to the abo

49、ve step.</p><p>  In order to carry out this procedure, you may select "Execute HELLO.EXE" option in"Build" menu. You may see your first MFC procedure -- appeared "hello world"

50、window. This window itself has: The title block, the size zoom area, are biggest and smallest button and so on. In the window,has "hello world". Please note, this procedure is complete. You may move the window,

51、 Shrink or Grow the window, Minimized it and so on. You only used the very few codes to complete a complete Window application proc</p><p>  From: Computer Lover</p><p><b>  附錄 附錄清單B</

52、b></p><p>  Visual C++ MFC 簡明教程</p><p><b>  一、MFC導(dǎo)論</b></p><p>  Visual C++ 不僅僅是一個編譯器,而且是一個全面的應(yīng)用程序開發(fā)環(huán)境,你可以充分利用具有面向?qū)ο筇匦缘?C++ 來開發(fā)出專業(yè)級的 Windows 應(yīng)用程序。為了能充分利用這些特性,你必須理解 C+

53、+ 程序設(shè)計(jì)語言。為了掌握C++,你就必須掌握 Microsoft 基本類庫 (MFC) 的層次結(jié)構(gòu)。該層次結(jié)構(gòu)包含了 Windows API 中的用戶界面部分,并使你能夠很容易的以面向?qū)ο蟮姆绞浇?Windows 應(yīng)用程序。這種層次結(jié)構(gòu)適用于所有版本的 Windows 并彼此兼容。你用 MFC 所建立的代碼是完全可移植的。</p><p>  如果你要建立一個 Windows 應(yīng)用程序,應(yīng)該如何下手?<

54、/p><p>  好的開端是從設(shè)計(jì)用戶界面開始。首先,你要決定什么樣的用戶能使用該程序并根據(jù)需要來設(shè)置相應(yīng)的用戶界面對象。Windows 用戶界面有一些標(biāo)準(zhǔn)的控制,如按鈕、菜單、滾動條和列表等,這對那些 Windows 用戶已經(jīng)是很熟悉了。要記住的是,作為程序員必須選擇一組控制并決定如何把其安排到屏幕上。傳統(tǒng)上,你需要在紙上做一下用戶界面的草圖,直到對各元素感到滿意為止。這對于一些比較小的項(xiàng)目,以及一些大項(xiàng)目的早期原

55、型階段是可行的。</p><p>  下一步,是要實(shí)現(xiàn)代碼。為任何 Windows 平臺建立應(yīng)用程序時,程序員都有兩種選擇:C 或 C++。 使用 C,程序員是在 Windows 應(yīng)用程序界面(API)的水平上編寫代碼。該界面是由幾百個 C 函數(shù)所組成,這些函數(shù)在Windows API 參考手冊中都有介紹。對于Windows NT,API 被稱為 “Win32 API”,以區(qū)別于其用于Windows 3.1的16

56、位 API。</p><p>  Microsoft 也提供了 C++ 庫,其位于任何 Windows API 之上,能夠使程序員的工作更容易。其就是Microsoft基本類庫(MFC),該庫的主要優(yōu)點(diǎn)是效率高。其減少了大量在建立 Windows 程序時必須編寫的代碼。同時還提供了所有一般 C++ 編程的優(yōu)點(diǎn)。MFC 是可移植的,例如,在 Windows 3.1下編寫的代碼可以很容易地移植到 Windows NT

57、 或 Windows 95 上。因此,MFC 很值得推薦的開發(fā)Windows 應(yīng)用程序的方法。</p><p>  當(dāng)你使用 MFC 時,你編寫的代碼是用來建立必要的用戶界面控制并定制其外觀。同時你還要編寫用來響應(yīng)用戶操作這些控制的代碼。例如,如果用戶單擊一個按鈕時,你應(yīng)該有代碼來響應(yīng)。這就是事件驅(qū)動代碼,其構(gòu)成了所有應(yīng)用程序。一旦應(yīng)用程序正確的響應(yīng)了所有允許的控制,其任務(wù)也就完成了。</p>&l

58、t;p>  你可以看出,使用 MFC 進(jìn)行 Windows 編程時是一件比較容易的過程。Visual C++ 應(yīng)用程序開發(fā)程序環(huán)境特別適合于使用 MFC(也有別的開發(fā)環(huán)境使用MFC),所以一起學(xué)習(xí) MFC 和 Visual C++ 能夠增強(qiáng)你的開發(fā)程序的能力。</p><p>  Windows支持幾種類型的應(yīng)用程序窗口。一個典型的應(yīng)用程序應(yīng)該活動在稱為“框架窗口”中。一個框架窗口是一個全功能的主窗口,用戶

59、可以改變尺寸、最小化、最大化等。Windows也支持兩種類型的對話框:模式和無模式對話框。模式對話框一旦出現(xiàn)在屏幕上,只有當(dāng)其退出時,屏幕上該應(yīng)用程序的其余部分才能響應(yīng)。無模式對話框出現(xiàn)在屏幕上時,程序的其余部分也可以做出響應(yīng),其就好像浮動在上面一樣。</p><p>  最簡單的 Windows 應(yīng)用程序是使用單文檔界面(SDI),只有一個框架窗口。Windows 的鐘表、PIF 編輯器、記事本等都是 SDI

60、應(yīng)用程序的例子。Windows 也提供了一種稱為多文檔界面的組織形式,其可用于更復(fù)雜的應(yīng)用程序。MDI 系統(tǒng)允許用戶在同一應(yīng)用程序中同時可以查看多個文檔。例如,一個文本編輯器可以允許用戶同時打開多個文本文件。使用 MDI 時,應(yīng)用程序有一個主窗口,在主窗口中有一些子窗口,每個子窗口中各自包含有各自的文檔。在MDI框架中,主窗口有一個主菜單,其對主框架中最頂端窗口有效。各子窗口都可以縮成圖標(biāo)或展開,MDI主窗口也可以變成桌面上的一個圖標(biāo)。

61、MDI界面可能會給你一種第二桌面的感覺,其對窗口的管理和刪除混亂的窗口有很大的幫助。</p><p>  你所建立的每一個應(yīng)用程序都會使用其自己的一套控制、菜單結(jié)構(gòu)以及對話框。應(yīng)用程序界面的好壞取決于你如何選擇和組織這些界面對象。Visual C++ 中的資源編輯器可以使你能容易的建立和定制這些界面對象。</p><p>  二、建立項(xiàng)目和編譯代碼</p><p>

62、  為了在 Visual C++ 中編譯代碼,你必須要建立一個項(xiàng)目。為了這么小的程序來建立一個項(xiàng)目可能有點(diǎn)小題大做,但是,在任何實(shí)際的程序中,項(xiàng)目的概念是非常有用的。一個項(xiàng)目主要保存著下面三種不同類型的信息:</p><p>  可以記住建立一個可執(zhí)行程序所需要的所有源程序代碼文件。在這個簡單的例子中,文件 HELLO.CPP 是唯一的源文件,但是在一個大型的應(yīng)用程序中,為了便于管理和維護(hù),你可以會有許多個不同的

63、源文件。項(xiàng)目會維護(hù)這些不同文件的列表,并當(dāng)你要建立下一個新的可執(zhí)行程序時,在必要時進(jìn)行編譯,其會記住針對你的應(yīng)用程序所使用的編譯器和連接器選項(xiàng)。例如,其會記住把哪個庫連接到了執(zhí)行程序中,你是否預(yù)編譯了頭文件等等。其會記住你想要建立的項(xiàng)目類型: 一個控制臺應(yīng)用程序,或一個窗口應(yīng)用程序等等。</p><p>  如果你已經(jīng)對項(xiàng)目文件有所了解,則會很容易明白作為機(jī)器產(chǎn)生的項(xiàng)目文件的作用?,F(xiàn)在,我們來建立一個簡單的項(xiàng)目,

64、并用其來編譯 HELLO.CPP。</p><p>  為此,首先從“File”菜單中選擇“New”選項(xiàng)。在“Projects”標(biāo)簽中,單擊“Win32 Application”。在“Location”域中輸入一個合適的路徑名或單擊“Browse”按鈕來選擇一個。在“Project name”中輸入“hello”作為項(xiàng)目名稱。這時候你會看到“hello”也會出現(xiàn)在“Location”域中。單擊“OK”按鈕。Vis

65、ual C++ 會建立一個新的稱為HELLO的目錄,并把所有的項(xiàng)目文件 HELLO.OPT、HELLO.NCB、HELLO.DSP 和 HELLO.DSW 都放到該目錄中。如果你退出,以后再重新打開該項(xiàng)目,則可選擇 HELLO.DSW。</p><p>  現(xiàn)在,在屏幕的左邊,出現(xiàn)了三個標(biāo)簽。InfoView 標(biāo)簽仍然在,又新出現(xiàn)了 ClassView 和 FileView 標(biāo)簽。ClassView 標(biāo)簽會把你程

66、序中所有的類都列出來,F(xiàn)ileView 標(biāo)簽給出了項(xiàng)目中文件的列表。</p><p>  現(xiàn)在可以輸入程序的代碼了。在“File”菜單中選擇“New”選項(xiàng)來建立一個編輯窗口。在出現(xiàn)的對話框中,選擇“Files”標(biāo)簽和“Text File”。則會出現(xiàn) Visual C++ 的智能編輯器,你可以用其來輸入上面的程序代碼。輸入代碼時,你會發(fā)現(xiàn)編輯器會自動把不同類型的文本變成不同的顏色,如果你要改變其顏色或關(guān)閉顏色功能,

67、可選擇“Tools”菜單中“Options”選項(xiàng),然后選擇“Format”標(biāo)簽和“Source Windows”選項(xiàng)就可以修改。</p><p>  輸入完代碼后,選擇“File”菜單中的“Save”選項(xiàng)來保存。在 Visual C++ 新建立的目錄中,把其存成 HELLO.CPP 文件。</p><p>  現(xiàn)在選擇在“Project”菜單中選擇“Add To Project”選項(xiàng),再選

68、“Files...”。你會看到一個對話框供你選擇要添加的文件。</p><p>  在屏幕的左邊,單擊 FileView 標(biāo)簽,并雙擊標(biāo)有 HELLO 的圖標(biāo)。你會看到名為 HELLO.CPP 的文件。單擊 ClassView 標(biāo)簽,并雙擊文件夾圖標(biāo),你會看到程序中所有的類。任何時候你都可以使用 FileView 來刪除項(xiàng)目的文件,你只要單擊該文件,然后按鍵盤上的 delete 鍵。</p><

69、;p>  此時你必須告訴項(xiàng)目要使用MFC庫。如果你忽略了這一步,則項(xiàng)目在連接時會出錯,而出錯信息對你毫無幫助。選擇“Project”菜單的“Settings”。在出現(xiàn)的對話框中選擇“General”標(biāo)簽。在“Microsoft Foundation Classes”組合框中,選擇“Use MFC in a Shared DLL”。然后關(guān)閉對話框。</p><p>  我們已經(jīng)建立了項(xiàng)目文件,并調(diào)整了設(shè)置,你

70、現(xiàn)在可以準(zhǔn)備編譯 HELLO.CPP 程序了。在“Build”菜單中,你會發(fā)現(xiàn)有三個不同的編譯選項(xiàng):</p><p>  Compile HELLO.CPP (只有當(dāng)含有 HELLO.CPP 的窗口處于激活狀態(tài)時才可)</p><p>  Build HELLO.EXE </p><p>  Rebuild All </p><p>  第一

71、個選項(xiàng)只是編譯源文件并形成目標(biāo)文件。該選項(xiàng)不能完成連接任務(wù),所以其只對快速編譯一些源文件以檢查錯誤有用。第二個選項(xiàng)編譯自上次編譯后所修改的所有源文件,并連接形成可執(zhí)行文件。第三個選項(xiàng)要重新編譯和連接所有的源文件。</p><p>  我們可以選擇“Build HELLO.EXE”來編譯和連接代碼。Visual C++ 會建立一個名為“Debug”的新子目錄,并把 HELLO.EXE 放在該目錄中。該子目錄的文件都

72、是可以再產(chǎn)生的,所以你可以對其任意刪除。</p><p>  如果你發(fā)現(xiàn)了編譯錯誤,雙擊輸出窗口中的錯誤信息。這時編輯器會把你帶到出錯的位置處。檢查你的代碼是否有問題,如果有,就修改之。如果你看到大量的連接錯誤,則可能你在建立項(xiàng)目對話框中所指定的項(xiàng)目類型不對。你可以把該項(xiàng)目所在的子目錄刪除,然后再重新按上面的步驟來建立。</p><p>  為了執(zhí)行該程序,你可選則“Build”菜單中的“

73、Execute HELLO.EXE”選項(xiàng)。你就可以看到你的第一個MFC程序了---出現(xiàn)一個帶有“hello world”的窗口。該窗口本身帶有:標(biāo)題欄、尺寸縮放區(qū)、最大和最小按鈕等等。在窗口上,有一個標(biāo)有“hello world”。請注意,該程序是完整的。你可以移動窗口、縮放窗口、最小化等。你只使用了很少的代碼就完成了一個完整的Window 應(yīng)用程序。這就是使用MFC的優(yōu)點(diǎn)。所有的細(xì)節(jié)問題都有MFC來處理。</p><

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 眾賞文庫僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論