visual c++简明教程外文文献.docx_第1页
visual c++简明教程外文文献.docx_第2页
visual c++简明教程外文文献.docx_第3页
visual c++简明教程外文文献.docx_第4页
visual c++简明教程外文文献.docx_第5页
已阅读5页,还剩12页未读 继续免费阅读

下载本文档

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

文档简介

Visual C+ MFC concise courseMFC introductory remarksVisual C+ not merely is a compiler. It is a comprehensive 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 understand 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 enabled you very easily to establish the Windows application procedure by the object-oriented way. This kind of level structure is suitable to all editions Windows and each other is compatible. You use the code which MFC establishes are definitely may transplant.If you want establish a Windows application procedure, how should start?The good beginning is from designning user contact surface. First, you must decide what kind of user 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 tabulates 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 them to the screen. Traditionaly, you need to make the schematic diagram of the user contact surface on the paper, until you satified with various elements. This is possible to some small project, as well as some big project at early time prototype stages.The next step, is 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 surface (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 called Win32 API, distinguishes to it uses in Windows 3.1 16 API.Microsoft has also provided the C+ storehouse, it is located above any Windows API, can make programmers work to be easier. It is the Microsoft 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 merit. MFC can be transplant, for example, the code which 3.1 compiles in Windows may very easily transplant to Windows NT or Windows 95. Therefore, MFC is worth the development Windows applicationprocedure method very much which recommends.When you uses MFC, you compile the code is uses to establish 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 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 completed.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 development environments to use MFC), therefore studies MFC and Visual C+ together can strengthen your development procedure ability.Windows supports several kind of types application procedure windows. 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 supports 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- pattern dialog box appears on the screen, other parts of the application procedure will respond, it like fluctuates on the screen.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 are 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 the same application procedure. For example, a text editor may allow the user open many text documents at same time. When uses MDI, the application procedure has a main window, has some sub- windows in the host window, in each stature window respectively contains its respective documents. In the MDI frame, the main window has a main menu, it effective to the peakest window in the host frame. Each sub- window all can flod or unflod into a chart sign, the MDI host window also can be aa chart sign. The MDI contact surface possibly can give you second tabletop feeling, it give us very big help for the window management and the deletion chaotic window.Each procedure you established may use its own control, menu structure as well as the dialog box. To choose a good application procedure contact surface is decided how to chooses and organizes these contact surface objects. Visual C+ resources editor may enable you eestablishment and has custom-made these contact surface objects.Establishment project and translation codeIn order to translates the code in Visual C+, you must have to establish a project. In order to the such small procedure 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 information: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 application 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 translates them when you establish the next executive routine.It can remember uses the compiler and the coupling option in view of yours application procedure. For example, it can remember which storehouse connected in the executive routine, whether you translated in advance document and so on.It can remember the project type which establishes: A control bench application procedure, or window application procedure and so on.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 project, and translates HELLO.CPP with it.Therefore, first in the menu chooses New from File the option. In Projects in the label, single-clicks Win32 Application.Inputs an appropriate way name in Location territory or single-clicks Browse button to choose.Inputs hello in Project nameas the project name. This time you can see 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.DSP and HELLO.DSW into this contents. If you withdraw, later again rewill open this project, then might choose HELLO.DSW.Now, in the screens 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, the FileView label give document tabulating in the project.Now it allowed to input routine code. Chooses New in File meno to establish an editor window. In appears in dialog 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 automatically turn the different type texts into different colors. If you wanteasily tochange its color or the close color function, you can choose “Optionsin Tools menu, then chooes Format label and Source Windows option to revise.After inputs the code, choose Save option inFilemenu to preserves. In Visual C+ new establishment ontents, saves it to HELLO.CPP document.Now chooses Add To Project option inProjectmenu,and chooses Files. . You can see a dialog box for you to chooses the documents which you want to appent.In the screen left side, single-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 use FileView to delete the project document, you only single-click this document, then click delete key on keyboard.This time you must tell the project to use MFC storehouse. If you neglected this step, the project in connection time can make a mistake, but mistake information will not give you any help. Choose SettingsinProject menu. In appears dialog box chooses General label. In Microsoft Foundation Classes Combined frame, choose Use MFC in a Shared DLL. Then close dialog box.We have already established the project document, and has adjusted the establishment, you now were allowed to translate the HELLO. CPP procedure. In Build menu, you can discover three different translations options:Compile HELLO.CPP (Only when includes HELLO.CPP window in active way)Build HELLO.EXERebuild AllThe first option only translates the source document and forms their goal document. This option 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 make the execution file. The third option must retranslate and the connection all sources document.We may choose Build HELLO.EXE to translate and the connection code. Visual C+ can establish Debug new sub-directory, and puts HELLO.EXE in this contents. This sub-directory documents can all reproduce, therefore you may wilfully delete them.If you discovered the translation 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 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 above step.In order to carry out this procedure, you may select Execute HELLO.EXE option inBuild menu. You may see your first MFC procedure - appeared hello world 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, Shrink or Grow the window, Minimized it and so on. You only used the very few codes to complete a complete Window application procedure. This is the merit of MFC using. MFC will process all detail questions.From: Computer LoverVisual C+ MFC 简明教程一、MFC导论Visual C+ 不仅仅是一个编译器,而且是一个全面的应用程序开发环境,你可以充分利用具有面向对象特性的 C+ 来开发出专业级的 Windows 应用程序。为了能充分利用这些特性,你必须理解 C+ 程序设计语言。为了掌握C+,你就必须掌握 Microsoft 基本类库(MFC)的层次结构。该层次结构包含了 Windows API 中的用户界面部分,并使你能够很容易的以面向对象的方式建立 Windows 应用程序。这种层次结构适用于所有版本的 Windows 并彼此兼容。你用 MFC 所建立的代码是完全可移植的。如果你要建立一个 Windows 应用程序,应该如何下手?好的开端是从设计用户界面开始。首先,你要决定什么样的用户能使用该程序并根据需要来设置相应的用户界面对象。Windows 用户界面有一些标准的控制,如按钮、菜单、滚动条和列表等,这对那些 Windows 用户已经是很熟悉了。要记住的是,作为程序员必须选择一组控制并决定如何把其安排到屏幕上。传统上,你需要在纸上做一下用户界面的草图,直到对各元素感到满意为止。这对于一些比较小的项目,以及一些大项目的早期原型阶段是可行的。下一步,是要实现代码。为任何 Windows 平台建立应用程序时,程序员都有两种选择:C 或 C+。使用 C,程序员是在 Windows 应用程序界面(API)的水平上编写代码。该界面是由几百个 C 函数所组成,这些函数在Windows API 参考手册中都有介绍。对于Windows NT,API 被称为“Win32 API”,以区别于其用于Windows 3.1的16位 API。Microsoft 也提供了 C+ 库,其位于任何 Windows API 之上,能够使程序员的工作更容易。其就是Microsoft基本类库(MFC),该库的主要优点是效率高。其减少了大量在建立 Windows 程序时必须编写的代码。同时还提供了所有一般 C+ 编程的优点。MFC 是可移植的,例如,在 Windows 3.1下编写的代码可以很容易地移植到 Windows NT 或 Windows 95 上。因此,MFC 很值得推荐的开发Windows 应用程序的方法。当你使用 MFC 时,你编写的代码是用来建立必要的用户界面控制并定制其外观。同时你还要编写用来响应用户操作这些控制的代码。例如,如果用户单击一个按钮时,你应该有代码来响应。这就是事件驱动代码,其构成了所有应用程序。一旦应用程序正确的响应了所有允许的控制,其任务也就完成了。你可以看出,使用 MFC 进行 Windows 编程时是一件比较容易的过程。Visual C+ 应用程序开发程序环境特别适合于使用 MFC(也有别的开发环境使用MFC),所以一起学习 MFC 和 Visual C+ 能够增强你的开发程序的能力。Windows支持几种类型的应用程序窗口。一个典型的应用程序应该活动在称为“框架窗口”中。一个框架窗口是一个全功能的主窗口,用户可以改变尺寸、最小化、最大化等。Windows也支持两种类型的对话框:模式和无模式对话框。模式对话框一旦出现在屏幕上,只有当其退出时,屏幕上该应用程序的其余部分才能响应。无模式对话框出现在屏幕上时,程序的其余部分也可以做出响应,其就好像浮动在上面一样。最简单的 Windows 应用程序是使用单文档界面(SDI),只有一个框架窗口。Windows 的钟表、PIF 编辑器、记事本等都是 SDI 应用程序的例子。Windows 也提供了一种称为多文档界面的组织形式,其可用于更复杂的应用程序。MDI 系统允许用户在同一应用程序中同时可以查看多个文档。例如,一个文本编辑器可以允许用户同时打开多个文本文件。使用 MDI 时,应用程序有一个主窗口,在主窗口中有一些子窗口,每个子窗口中各自包含有各自的文档。在MDI框架中,主窗口有一个主菜单,其对主框架中最顶端窗口有效。各子窗口都可以缩成图标或展开,MDI主窗口也可以变成桌面上的一个图标。MDI界面可能会给你一种第二桌面的感觉,其对窗口的管理和删除混乱的窗口有很大的帮助。你所建立的每一个应用程序都会使用其自己的一套控制、菜单结构以及对话框。应用程序界面的好坏取决于你如何选择和组织这些界面对象。Visual C+ 中的资源编辑器可以使你能容易的建立和定制这些界面对象。二、建立项目和编译代码为了在 Visual C+ 中编译代码,你必须要建立一个项目。为了这么小的程序来建立一个项目可能有点小题大做,但是,在任何实际的程序中,项目的概念是非常有用的。一个项目主要保存着下面三种不同类型的信息:可以记住建立一个可执行程序所需要的所有源程序代码文件。在这个简单的例子中,文件 HELLO.CPP 是唯一的源文件,但是在一个大型的应用程序中,为了便于管理和维护,你可以会有许多个不同的源文件。项目会维护这些不同文件的列表,并当你要建立下一个新的可执行程序时,在必要时进行编译,其会记住针对你的应用程序所使用的编译器和连接器选项。例如,其会记住把哪个库连接到了执行程序中,你是否预编译了头文件等等。其会记住你想要建立的项目类型:一个控制台应用程序,或一个窗口应用程序等等。如果你已经对项目文件有所了解,则会很容易明白作为机器产生的项目文件的作用。现在,我们来建立一个简单的项目,并用其来编译 HELLO.CPP。为此,首先从“File”菜单中选择“New”选项。在“Projects”标签中,单击“Win32 Application”。在“Location”域中输入一个合适的路径名或单击“Browse”按钮来选择一个。在“Project name”中输入“hello”作为项目名称。这时候你会看到“hello”也会出现在“Location”域中。单击“OK”按钮。Visual C+ 会建立一个新的称为HELLO的目录,并把所有的项目文件 HELLO.OPT、HELLO.NCB、HELLO.DSP 和 HELLO

温馨提示

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

评论

0/150

提交评论