【正文】
e derived class has application architecture, window class, exception classes, class files, graphical interface of object class and database support, collection classes non CObject derived classes are more monly used tools, the main Internet tools, simple data type, auxiliary support class, OLF class, etc..C++ Visual provides some order to generate different types of programs, and provide a variety of application framework, the most monly used is the MFC APPWizard (exe) application wizard, you can build a single document interface (SDI) program, a multiple document interface (MDI) program and application program based on the dialog box + + development environment also provides class wizard (Class Wizard) tools, you can realize the maintenance of the application structure, management message mapping, add delete dialog class member variables and other functions, and in new visual development tools, the class wizard dialog box has been canceled,most of the features are added to the property window.A monly used class of MFC is CWnd (window) CString (string), CFile classes (files), CArchive (archive), CPoint a CSize crect (point, size, rectangular type) and collection classes. MFC Application Framework Currently in the field of puter software, there have been a lot of program framework is developed, and some are used for the preparation of standalone programs, some suitable for network applications, and some for game programming, etc..MFC application framework is built on the basis of the C++ class library, which defines the structure of the by the MFC application framework has many kinds, such as single document procedures, multi document program, based on dialog procedures, MFC dynamic link library, ActiveX control procedures can provided by VC + + program guide tool,without entering any code, you can generate a basic structure of the required program type,and this structure is often encapsulated in a large number of code to achieve a lot of details without the need to understand the programmer. If there is no such procedural framework, can only use Windows API Win32 programming, programmers have rich experience and the knowledge of program debugging capabilities, which for C + + beginners is not realistic.MFC application framework makes full use of the C + + virtual functions and polymorphism of the functional properties, first defined some powerful base class, program frame and constructed by these classes of object pointers, are many useful virtual function declared in the class, use object pointer to call the virtual function key positions in the ask do is to inherit these libraries, add new code to a derived class, according to the need to override the base class virtual function. Then the application framework base class pointer to replace the derived class pointer can be.Programmers first need to understand the simple MFC application framework, and according to the specific task to write the corresponding program, the programmer can provide with MFC in the large number of classes to define the objects, can also custom class, but also to the library in some kind of give birth to a new class of futurism, overloaded or extend the base class function. When the user39。s application design of some of the MFC class library functions, you can use the third party library to achieve.附錄B 漢語(yǔ)翻譯 MFCMFC是微軟基礎(chǔ)類庫(kù)的縮寫(Microsoft Foundation Classes library),。MFC包含了用來(lái)開發(fā)C++程序和Windows程序的基礎(chǔ)類,MFC提供了大量的工具類,提高了程序員的編程效率,如簡(jiǎn)單數(shù)據(jù)類、文件服務(wù)類、集合類、Internet 工具類等。更重要的是MFC提供了一系列Windows應(yīng)用程序框架,定義了應(yīng)用程序結(jié)構(gòu),實(shí)現(xiàn)了應(yīng)用程序的公共部分,包括窗口、消息映射機(jī)制、對(duì)話框、繪圖設(shè)備、繪圖對(duì)象、標(biāo)準(zhǔn)Windows控件等元素,封裝了大部分的Windows API函數(shù),降低了編程難度,提高了應(yīng)用程序的開發(fā)速度和質(zhì)量。從類的層次角度看,MFC的類還可以分成兩大類:CObject的派生類和非CObject的派生類。CObject派生類都具有CObject類的特性,如可以序列化、運(yùn)行時(shí)類信息訪問機(jī)制、對(duì)象診斷輸出、與集合類結(jié)合使用等,相關(guān)的派生類有應(yīng)用程序體系結(jié)構(gòu)類、窗口類、異常類、文件類、圖形界面對(duì)象類、數(shù)據(jù)庫(kù)支持類、集合類等;而非CObject派生類都是比較常用的工具類,主要有Internet工具類、簡(jiǎn)單數(shù)據(jù)類、輔助支持類、OLF類等。Visual C++提供了一些工具。為了生成不同的程序類型,而提供了多種應(yīng)用程序框架,最常用的是MFC APPWizard(exe)應(yīng)用程序向?qū)?,可以建立單文檔界面(SDI)程序、多文檔界面(MDI)程序和基于對(duì)話框程序的應(yīng)用程序。VC++ 開發(fā)環(huán)境中還提供類向?qū)В–lass Wizard)工具,可以實(shí)現(xiàn)維護(hù)應(yīng)用程序的結(jié)構(gòu)、管理消息映射、添加刪除對(duì)話框類的成員變量等功能,而在新版的Visual C++.NET開發(fā)工具中,類向?qū)?duì)話框已經(jīng)取消了,其大部分功能都加入到屬性窗口中了。MFC的常用類有CWnd(窗口類)、CString(字符串類)、CFile(文件類)、CArchive(存檔類)、CPoint CSize CRect(點(diǎn)、大小、矩形類) 以及集合類。 MFC應(yīng)用程序框架目前在計(jì)算機(jī)軟件領(lǐng)域,已經(jīng)有很多的程序框架被開發(fā)出來(lái),有的用于編寫單機(jī)程序,有的適合網(wǎng)絡(luò)應(yīng)用,有的針對(duì)游戲編程等。MFC的應(yīng)用程序框架就是在C++類庫(kù)的基礎(chǔ)上建立起來(lái)的,它定義了程序的結(jié)構(gòu)。MFC提供的應(yīng)用程序框架有很多種,如單文檔程序、多文檔程序、基于對(duì)話框的程序、MFC動(dòng)態(tài)鏈接庫(kù)程序、ActiveX控件程序等,可以利用VC++提供的程序向?qū)Чぞ?,不用輸入任何代碼,就可以生成一個(gè)所需程序類型的基本結(jié)構(gòu),而這種結(jié)構(gòu)往往封裝了大量的實(shí)現(xiàn)代碼,隱藏了很多無(wú)需程序員了解的細(xì)節(jié)。如果沒有這樣的程序框架,就只能利用Windows API進(jìn)行Win32編程,則要求程序員有豐富的知識(shí)經(jīng)驗(yàn)和程序調(diào)試能力,這對(duì)于C++語(yǔ)言的初學(xué)者來(lái)說(shuō)是不現(xiàn)實(shí)的。MFC程序框架充分利用了C++語(yǔ)言中虛函數(shù)與多態(tài)的功能特性,先定義好了一些功能強(qiáng)大的基類,然后用這些類的對(duì)象指針構(gòu)建程序框架,在這些類中聲明了許多有用的虛函數(shù),在框架中的關(guān)鍵位置利用對(duì)象指針調(diào)用這些虛函數(shù)。編程者索要做的就是繼承這些類庫(kù),為派生類添加新的代碼,根據(jù)需要重寫基類提供的虛函數(shù),接著把應(yīng)用程序框架中的基類指針替換成派生類指針即可。程序員首先需要簡(jiǎn)單了解MFC程序框架的構(gòu)成,然后就可以針對(duì)具體任務(wù)編寫相應(yīng)的程序了,程序員可以用MFC中提供的大量的類來(lái)定義對(duì)象,也可以自定義類,還能以類庫(kù)中的某些類為基礎(chǔ)類來(lái)派生新類,重載或擴(kuò)充基類的功能。當(dāng)用戶的應(yīng)用程序設(shè)計(jì)了某些MFC類庫(kù)中沒有的功能,也可以使用第三方的類庫(kù)來(lái)實(shí)現(xiàn)。38