【正文】
large. It can take quite a bit of code simply to figure out which object was clicked and what to do about it. Fortunately, you can work at a much higher level of abstraction. In MFC, almost all these lowlevel implementation details are handled for you. If you want to place a user interface object on the screen, you create it with two lines of code. If the user clicks on a button, the button does everything needed to update its appearance on the screen and then calls a prearranged function in your program. This function contains the code that implements the appropriate action for the button. MFC handles all the details for you: You create the button and tell it about a specific handler function, and it calls your function when the user presses it. Tutorial 4 shows you how to handle events using message maps An Example One of the best ways to begin understanding the structure and style of a typical MFC program is to enter, pile, and run a small example. The listing below contains a simple hello world program. If this is the first time you39。s standpoint, the systems are all similar in concept, although they differ radically in their specifics. To create a GUI program, the programmer first puts all of the needed user interface controls into a window. For example, if the programmer is trying to create a simple program such as a Fahrenheit to Celsius converter, then the programmer selects user interface objects appropriate to the task and displays them on screen. In this example, the programmer might let the user enter a temperature in an editable text area, display the converted temperature in another uneditable text area, and let the user exit the program by clicking on a pushbutton labeled quit. As the user manipulates the application39。s job easier. Called the Microsoft Foundation Class library (MFC), this library39。s API Reference books. For Window39。 計(jì)算機(jī)專業(yè)畢業(yè)設(shè)計(jì) 外文翻譯 Visual C++ MFC 簡(jiǎn)要介紹 工 學(xué) 部 工學(xué)一部 專 業(yè) 計(jì)算機(jī)科學(xué)與技術(shù) 班 級(jí) 4418101 學(xué) 號(hào) 202020201038 姓 名 張 為 指導(dǎo)教師 史 俊 負(fù)責(zé)教師 沈陽(yáng)航空工業(yè)學(xué)院 北方科技學(xué)院 2020 年 7 月 沈陽(yáng)航空工業(yè)學(xué)院北方科技學(xué)院畢業(yè)設(shè)計(jì) (外文翻譯 ) 1 Introduction to MFC Programming with Visual C++ Version by Marshall Brain Visual C++ is much more than a piler. It is a plete application development environment that, when used as intended, lets you fully exploit the object oriented nature of C++ to create professional Windows applications. In order to take advantage of these features, you need to understand the C++ programming language. If you have never used C++, please turn to the C++ tutorials in the C/C++ Tutorials page for an introduction. You must then understand the Microsoft Foundation Class (MFC) hierarchy. This class hierarchy encapsulates the user interface portion of the Windows API, and makes it significantly easier to create Windows applications in an object oriented way. This hierarchy is available for and patible with all versions of Windows. The code you create in MFC is extremely portable. These tutorials introduce the fundamental concepts and vocabulary behind MFC and event driven programming. In this tutorial you will enter, pile, and run a simple MFC program using Visual C++. Tutotial 2 provides a detailed explanation of the code used in Tutorial 1. Tutorial 3 discusses MFC controls and their customization. Tutorial 4 covers message maps, which let you handle events in MFC. What is the Microsoft Foundations Class Library? Let39。s say you want to create a Windows application. You might, for example, need to create a specialized text or drawing editor, or a program that finds files on a large hard disk, or an application that lets a user visualize the interrelationships in a big data set. Where do you begin? A good starting place is the design of the user interface. First, decide what the user should be able to do with the program and then pick a set of user interface objects accordingly. The Windows user interface has a number of standard controls, such as buttons, menus, scroll bars, and lists, that are already familiar to Windows users. With this in mind, the programmer must choose a set of controls and decide how they should be arranged on screen. A timehonored procedure is to make a rough sketch of the proposed user interface (by tradition on a napkin or the back of an envelope) and play with the elements until they feel right. For small projects, or for the early prototyping phase of a larger project, this is sufficient. The next step is to implement the code. When creating a program for any Windows 沈陽(yáng)航空工業(yè)學(xué)院北方科技學(xué)院畢業(yè)設(shè)計(jì) (外文翻譯 ) 2 platform, the programmer has two choices: C or C++. With C, the programmer codes at the level of the Windows Application Program Interface (API). This interface consists of a collection of hundreds of C functions described in the Window39。s NT, the API is typically referred to as the Win32 API, to distinguish it from the original 16bit API of lowerlevel Windows products like Windows . Microsoft also provides a C++ library that sits on top of any of the Windows APIs and makes the programmer39。s primary advantage is efficiency. It greatly reduces the amount of code that must be written to create a Windows program. It also provides all the advantages normally found in C++ programming, such as inheritance and encapsulation. MFC is portable, so that, for example, code created under Windows can move to Windows NT or Windows 95 very easily. MFC is therefore the preferred method for developing Windows applications and will be used throughout these tutorials. When you use MFC, you write code that creates the necessary user interface controls and customizes their appearance. You also write code that responds when the user manipulates these controls. For exam