Visual-C++ MFC简要介绍大学毕业论文外文文献翻译及原文
- 格式:doc
- 大小:174.50 KB
- 文档页数:18
Introduction to MFC Programming with Visual C++ Version 6.xby Marshall BrainVisual C++ is much more than a compiler. It is a complete 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 compatible 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, compile, 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 LibraryLet'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 beginA 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 time-honored 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 Windowsplatform, 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 Window's API Reference books. For Window's NT, the API is typically referred to as the "Win32 API," to distinguish it from the original 16-bit API of lower-level Windows products like Windows 3.1.Microsoft also provides a C++ library that sits on top of any of the Windows APIs and makes the programmer's job easier. Called the Microsoft Foundation Class library (MFC), this library'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 3.1 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 example, if the user clicks a button, you want to have code in place that responds appropriately. It is this sort of event-handling code that will form the bulk of any application. Once the application responds correctly to all of the available controls, it is finished.You can see from this discussion that the creation of a Windows program is a straightforward process when using MFC. The goal of these tutorials is to fill in the details and to show the techniques you can use to create professional applications as quickly as possible. The Visual C++ application development environment is specifically tuned to MFC, so by learning MFC and Visual C++ together you can significantly increase your power as an application developer.Windows V ocabularyThe vocabulary used to talk about user interface features and software development in Windows is basic but unique. Here we review a few definitions to make discussion easier for those who are new to the environment.Windows applications use several standard user controls:Static text labelsPush buttonsList boxesCombo boxes (a more advanced form of list)Radio boxesCheck boxesEditable text areas (single and multi-line)Scroll barsYou can create these controls either in code or through a "resource editor" that can create dialogs and the controls inside of them. In this set of tutorials we will examine how to create them in code. See the tutorials on the AppWizard and ClassWizard for an introduction to the resource editor for dialogs.Windows supports several types of application windows. A typical application will live inside a "frame window". A frame window is a fully featured main window that the user can re-size, minimize, maximize to fill the screen, and so on. Windows also supports two types of dialog boxes: modal and modeless. A modal dialog box, once on the screen, blocks input to the rest of the application until it is answered. A modeless dialog box can appear at the same time as the application and seems to "float above" it to keep from being overlaid.Most simple Windows applications use a Single Document Interface, or SDI, frame. The Clock, PIF editor, and Notepad are examples of SDI applications. Windows also provides an organizing scheme called the Multiple Document Interface, or MDI for more complicated applications. The MDI system allows the user to view multiple documents at the same time within a single instance of an application. For example, a text editor might allow the user to open multiple files simultaneously. When implemented with MDI, the application presents a large application window that can hold multiple sub-windows, each containing a document. The single main menu is held by the main application window and it applies to the top-most window held within the MDI frame. Individual windows can be iconified or expanded as desired within the MDI frame, or the entire MDI frame can be minimized into a single icon on the desktop. The MDI interface gives the impression of a second desktop out on the desktop, and it goes a long way towards organizing and removing window clutter. Each application that you create will use its own unique set of controls, its own menu structure, and its own dialog boxes. A great deal of the effort that goes into creating any good application interface lies in the choice and organization of these interface objects. Visual C++, along with its resource editors, makes the creation and。
毕业论文外文翻译两篇篇一:毕业论文外文翻译外文资料翻译译文:概述是一个统一的Web开发模型,它包括您使用尽可能少的代码生成企业级Web应用程序所必需的各种服务。
作为.NETFramework的一部分提供。
当您编写应用程序的代码时,可以访问.NETFramework中的类。
您可以使用与公共语言运行库(CLR)兼容的任何语言来编写应用程序的代码,这些语言包括MicrosoftVisualBasic、C#、和J#。
使用这些语言,可以开发利用公共语言运行库、类型安全、继承等方面的优点的应用程序。
包括:∙页和控件框架∙编译器∙安全基础结构∙状态管理功能∙应用程序配置∙运行状况监视和性能功能∙调试支持∙XMLWebservices框架∙可扩展的宿主环境和应用程序生命周期管理∙可扩展的设计器环境页和控件框架是一种编程框架,它在Web服务器上运行,可以动态地生成和呈现网页。
可以从任何浏览器或客户端设备请求网页,会向请求浏览器呈现标记(例如HTML)。
通常,您可以对多个浏览器使用相同的页,因为会为发出请求的浏览器呈现适当的标记。
但是,您可以针对诸如MicrosoftInternetExplorer6的特定浏览器设计网页,并利用该浏览器的功能。
支持基于Web的设备(如移动电话、手持型计算机和个人数字助理(PDA))的移动控件。
网页是完全面向对象的。
在网页中,可以使用属性、方法和事件来处理HTML元素。
页框架为响应在服务器上运行的代码中的客户端事件提供统一的模型,从而使您不必考虑基于Web的应用程序中固有的客户端和服务器隔离的实现细节。
该框架还会在页处理生命周期中自动维护页及该页上控件的状态。
使用页和控件框架还可以将常用的UI功能封装成易于使用且可重用的控件。
控件只需编写一次,即可用于许多页并集成到网页中。
这些控件在呈现期间放入网页中。
页和控件框架还提供各种功能,以便可以通过主题和外观来控制网站的整体外观和感觉。
可以先定义主题和外观,然后在页面级或控件级应用这些主题和外观。
安徽工业大学工商学院毕业设计(论文)外文文献翻译基于Visual C++的图像检测模块设计毕业设计(论文)题目翻译(1)题目基于PAC的实时人脸检测和跟踪方法翻译(2)题目基于半边脸的人脸检测系仪器仪表专业测控技术与仪器姓名班级学号指导教师译文一基于PAC的实时人脸检测和跟踪方式1摘要:这篇文章提出了复杂背景条件下,实现实时人脸检测和跟踪的一种方式。
这种方式是以主要成分分析技术为基础的。
为了实现人脸的检测,首先,我们要用一个肤色模型和一些动作信息(如:姿势、手势、眼色)。
然后,使用PAC技术检测这些被检验的区域,从而判定人脸真正的位置。
而人脸跟踪基于欧几里德(Euclidian)距离的,其中欧几里德距离在位于以前被跟踪的人脸和比来被检测的人脸之间的特征空间中。
用于人脸跟踪的摄像控制器以这样的方式工作:利用平衡/(pan/tilt)平台,把被检测的人脸区域控制在屏幕的中央。
这个方式还可以扩展到其他的系统中去,例如电信会议、入侵者检查系统等等。
1.引言视频信号处理有许多应用,例如鉴于通讯可视化的电信会议,为残疾人办事的唇读系统。
在上面提到的许多系统中,人脸的检测喝跟踪视必弗成缺的组成部分。
在本文中,涉及到一些实时的人脸区域跟踪[1-3]。
一般来说,按照跟踪角度的分歧,可以把跟踪方式分为两类。
有一部分人把人脸跟踪分为基于识别的跟踪喝基于动作的跟踪,而其他一部分人则把人脸跟踪分为基于边缘的跟踪和基于区域的跟踪[4]。
基于识别的跟踪是真正地以对象识别技术为基础的,而跟踪系统的性能是受到识别方式的效率的限制。
基于动作的跟踪是依赖于动作检测技术,且该技术可以被分成视频流(optical flow)的(检测)方式和动作—能量(motion-energy)的(检测)方式。
基于边缘的(跟踪)方式用于跟踪一幅图像序列的边缘,而这些边缘凡是是主要对象的边界线。
然而,因为被跟踪的对象必需在色彩和光照条件下显示出明显的边缘变化,所以这些方式会遭遇到彩色和光照的变化。
毕业设计(论文)外文原文及译文一、外文原文MCUA microcontroller (or MCU) is a computer-on-a-chip. It is a type of microcontroller emphasizing self-sufficiency and cost-effectiveness, in contrast to a general-purpose microprocessor (the kind used in a PC).With the development of technology and control systems in a wide range of applications, as well as equipment to small and intelligent development, as one of the single-chip high-tech for its small size, powerful, low cost, and other advantages of the use of flexible, show a strong vitality. It is generally better compared to the integrated circuit of anti-interference ability, the environmental temperature and humidity have better adaptability, can be stable under the conditions in the industrial. And single-chip widely used in a variety of instruments and meters, so that intelligent instrumentation and improves their measurement speed and measurement accuracy, to strengthen control functions. In short,with the advent of the information age, traditional single- chip inherent structural weaknesses, so that it show a lot of drawbacks. The speed, scale, performance indicators, such as users increasingly difficult to meet the needs of the development of single-chip chipset, upgrades are faced with new challenges.The Description of AT89S52The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8K bytes of In-System Programmable Flash memory. The device is manufactured using Atmel's high-density nonvolatile memory technology and is compatible with the industry-standard 80C51 instruction set and pinout. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with In-System Programmable Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcontroller which provides a highly-flexible and cost-effective solution to many embedded control applications.The AT89S52 provides the following standard features: 8K bytes ofFlash, 256 bytes of RAM, 32 I/O lines, Watchdog timer, two data pointers, three 16-bit timer/counters, a six-vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator, and clock circuitry. In addition, the AT89S52 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port, and interrupt system to continue functioning. The Power-down mode saves the RAM contents but freezes the oscillator, disabling all other chip functions until the next interrupt or hardware reset.Features• Compatible with MCS-51® Products• 8K Bytes of In-System Programmable (ISP) Flash Memory– Endurance: 1000 Write/Erase Cycles• 4.0V to 5.5V Operating Range• Fully Static Operation: 0 Hz to 33 MHz• Three-level Program Memory Lock• 256 x 8-bit Internal RAM• 32 Programmable I/O Lines• Three 16-bit Timer/Counters• Eight Interrupt Sources• Full Duplex UART Serial Channel• Low-power Idle and Power-down Modes• Interrupt Recovery from Power-down Mode• Watchdog Timer• Dual Data Pointer• Power-off FlagPin DescriptionVCCSupply voltage.GNDGround.Port 0Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high-impedance inputs.Port 0 can also be configured to be the multiplexed low-order address/data bus during accesses to external program and data memory. In this mode, P0 has internal pullups.Port 0 also receives the code bytes during Flash programming and outputs the code bytes during program verification. External pullups are required during program verification.Port 1Port 1 is an 8-bit bidirectional I/O port with internal pullups. The Port 1 output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pullups.In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively.Port 1 also receives the low-order address bytes during Flash programming and verification.Port 2Port 2 is an 8-bit bidirectional I/O port with internal pullups. The Port 2 output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pullups.Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that use 16-bit addresses (MOVX @ DPTR). In this application, Port 2 uses strong internal pull-ups when emitting 1s. During accesses to external data memory that use 8-bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special Function Register.Port 2 also receives the high-order address bits and some control signals during Flash programming and verification.Port 3Port 3 is an 8-bit bidirectional I/O port with internal pullups. The Port 3 output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pullups.Port 3 also serves the functions of various special features of the AT89S52, as shown in the following table.Port 3 also receives some control signals for Flash programming and verification.RSTReset input. A high on this pin for two machine cycles while the oscillator is running resets the device. This pin drives High for 96 oscillator periods after the Watchdog times out. The DISRTO bit in SFR AUXR (address 8EH) can be used to disable this feature. In the default state of bit DISRTO, the RESET HIGH out feature is enabled.ALE/PROGAddress Latch Enable (ALE) is an output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) during Flash programming.In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency and may be used for external timing or clocking purposes. Note, however, that one ALE pulse is skipped during each access to external data memory.If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode.PSENProgram Store Enable (PSEN) is the read strobe to external program memory. When the AT89S52 is executing code from external program memory, PSENis activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory.EA/VPPExternal Access Enable. EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal program executions.This pin also receives the 12-volt programming enable voltage (VPP) during Flash programming.XTAL1Input to the inverting oscillator amplifier and input to the internal clock operating circuit.XTAL2Output from the inverting oscillator amplifier.Special Function RegistersNote that not all of the addresses are occupied, and unoccupied addresses may not be implemented on the chip. Read accesses to these addresses will in general return random data, and write accesses will have an indeterminate effect.User software should not write 1s to these unlisted locations, since they may be used in future products to invoke new features. In that case, the reset or inactive values of the new bits will always be 0.Timer 2 Registers:Control and status bits are contained in registers T2CON and T2MOD for Timer 2. The register pair (RCAP2H, RCAP2L) are the Capture/Reload registers for Timer 2 in 16-bit capture mode or 16-bit auto-reload mode.Interrupt Registers:The individual interrupt enable bits are in the IE register. Two priorities can be set for each of the six interrupt sources in the IP register.Dual Data Pointer Registers: To facilitate accessing both internal and external data memory, two banks of 16-bit Data Pointer Registers areprovided: DP0 at SFR address locations 82H-83H and DP1 at 84H-85H. Bit DPS = 0 in SFR AUXR1 selects DP0 and DPS = 1 selects DP1. The user should always initialize the DPS bit to the appropriate value before accessing the respective Data Pointer Register.Power Off Flag:The Power Off Flag (POF) is located at bit 4 (PCON.4) in the PCON SFR. POF is set to “1” during power up. It can be set and rest under software control and is not affected by reset.Memory OrganizationMCS-51 devices have a separate address space for Program and Data Memory. Up to 64K bytes each of external Program and Data Memory can be addressed.Program MemoryIf the EA pin is connected to GND, all program fetches are directed to external memory. On the AT89S52, if EA is connected to VCC, program fetches to addresses 0000H through 1FFFH are directed to internal memory and fetches to addresses 2000H through FFFFH are to external memory.Data MemoryThe AT89S52 implements 256 bytes of on-chip RAM. The upper 128 bytes occupy a parallel address space to the Special Function Registers. This means that the upper 128 bytes have the same addresses as the SFR space but are physically separate from SFR space.When an instruction accesses an internal location above address 7FH, the address mode used in the instruction specifies whether the CPU accesses the upper 128 bytes of RAM or the SFR space. Instructions which use direct addressing access of the SFR space. For example, the following direct addressing instruction accesses the SFR at location 0A0H (which is P2).MOV 0A0H, #dataInstructions that use indirect addressing access the upper 128 bytes of RAM. For example, the following indirect addressing instruction, where R0 contains 0A0H, accesses the data byte at address 0A0H, rather than P2 (whose address is 0A0H).MOV @R0, #dataNote that stack operations are examples of indirect addressing, so the upper 128 bytes of data RAM are available as stack space.Timer 0 and 1Timer 0 and Timer 1 in the AT89S52 operate the same way as Timer 0 and Timer 1 in the AT89C51 and AT89C52.Timer 2Timer 2 is a 16-bit Timer/Counter that can operate as either a timer or an event counter. The type of operation is selected by bit C/T2 in the SFR T2CON (shown in Table 2). Timer 2 has three operating modes: capture, auto-reload (up or down counting), and baud rate generator. The modes are selected by bits in T2CON.Timer 2 consists of two 8-bit registers, TH2 and TL2. In the Timer function, the TL2 register is incremented every machine cycle. Since a machine cycle consists of 12 oscillator periods, the count rate is 1/12 of the oscillator frequency.In the Counter function, the register is incremented in response to a1-to-0 transition at its corresponding external input pin, T2. In this function, the external input is sampled during S5P2 of every machine cycle. When the samples show a high in one cycle and a low in the next cycle, the count is incremented. The new count value appears in the register during S3P1 of the cycle following the one in which the transition was detected. Since two machine cycles (24 oscillator periods) are required to recognize a 1-to-0 transition, the maximum count rate is 1/24 of the oscillator frequency. To ensure that a given level is sampled at least once before it changes, the level should be held for at least one full machine cycle.InterruptsThe AT89S52 has a total of six interrupt vectors: two external interrupts (INT0 and INT1), three timer interrupts (Timers 0, 1, and 2), and the serial port interrupt. These interrupts are all shown in Figure 10.Each of these interrupt sources can be individually enabled or disabledby setting or clearing a bit in Special Function Register IE. IE also contains a global disable bit, EA, which disables all interrupts at once.Note that Table 5 shows that bit position IE.6 is unimplemented. In the AT89S52, bit position IE.5 is also unimplemented. User software should not write 1s to these bit positions, since they may be used in future AT89 products. Timer 2 interrupt is generated by the logical OR of bits TF2 and EXF2 in register T2CON. Neither of these flags is cleared by hardware when the service routine is vectored to. In fact, the service routine may have to determine whether it was TF2 or EXF2 that generated the interrupt, and that bit will have to be cleared in software.The Timer 0 and Timer 1 flags, TF0 and TF1, are set at S5P2 of the cycle in which the timers overflow. The values are then polled by the circuitry in the next cycle. However, the Timer 2 flag, TF2, is set at S2P2 and is polled in the same cycle in which the timer overflows.二、译文单片机单片机即微型计算机,是把中央处理器、存储器、定时/计数器、输入输出接口都集成在一块集成电路芯片上的微型计算机。
附录:英文技术资料翻译英文原文:Microsoft Visual C++ 6.0 and MFC Brief IntroductionThe Visual C 6.0, referred to as VC or VC6.0, Microsoft introduced a C compiler, high-level language the program translated into machine language (low-level language). Visual C is a powerful visualization software development tools. , With its new version come out since 1993, Microsoft introduced the Visual C 1.0, Visual C has become the tool of choice for professional programmers to develop software. Microsoft Visual C NET (Visual C 7.0), but its application has great limitations, applies only to Windows 2000, Windows XP and Windows NT 4.0. Practice, are based more on the Visual C 6.0 as a platform.Features and shortcomingsCharacteristicVisual C, 6.0, developed by Microsoft, it is not only a C compiler, and a Windows operating system, a visual integrated development environment (integrated development environment, IDE). Visual C 6.0 is composed of many components, including editor, debugger, and AppWizard AppWizard, ClassWizard Class Wizard and other development tools. These components are integrated through a component called Developer Studio for the harmonious development environment. Microsoft's main software products. Visual C is a powerful visualization software development tools. , With its new version come out since 1993, Microsoft introduced the Visual C 1.0, Visual C has become the tool of choice for professional programmers to develop software. Microsoft Visual C NET (Visual C 7.0), but the limitations of its application only applies to Windows 2000, Windows XP and Windows NT 4.0. Practice, are based more on the Visual C 6.0 as a platform.Visual C, 6.0 to have syntax highlighting, automatic compiler functions and advanced debugging features known. For example, it allows users to remotely debug a single step. As well as allow the user during debugging to recompile the modified code, without having to restart the program being debugged. Compile and create the precompiled header file (the stdafx.h), the minimum reconstruction function and the cumulative link (link). These features significantly shorten the procedure edit, compile and link time to spend, particularly notable in thelarge-scale software projects.ShortcomingC is developed by C language, and also supports the C language compiler. Version 6.0 is the most used version of the classic. The biggest shortcoming is its relatively poor support for templates. The latest patch for SP6, the recommended installation, or prone to compile-time state of suspended animation. Supports only the Windows operating system. Currently found with windows 7 compatibility is not good, can not open the cpp file of the phenomenon may occur after a successful installation.MFCmfc is the abbreviation of the Microsoft Foundation Class Library, Microsoft implemented a c class library encapsulates most of the Windows API function, vc is the integrated development environment developed byMicrosoft Corporation c / c, the so-called integrated development environment, that is use it you can edit, co mpile, debug, instead of using the rotation operation of a variety of tools, greater flexibility. Sometimes people say vc it also refers to its internal compiler, integrated development environment must have a compiler, kernel, or what, such as DevC which the kernel of a compiler is the gcc. MFC is a class library, outside, or a framework, you should be tried, to create a new MFC project in vc, the development environment will help you automatically generate a lot of files at the same time it uses mfcxx.dll. xx is the version of mfc kernel, so you see less than the original SDK programming in the message loop, and things in your code, because the MFC framework to help you better package, so you can concentrate on consideration of your application logic, and what not each programming must be repeated, but is a common framework, not the best targeted, of course, they also lose some flexibility and efficiency of the MFC package is very shallow, so little loss of efficiency flexibility, although there are many defects, but still a good thing.MFC and Win32The MFC the Object and the Windows the Object of the relationship between MFC package yes encapsulation of the Win32 API, therefore, understand the Windows Object and the MFC the Object (C, + + object, a C, + + class's instance) between the understanding of MFC's key one. The so-called the Windows the Object (the Windows object) is under Win32 use handle, said of the Windows operating system object; so-called the MFC the Object (the MFC object) is C, + + object, is a C + + class's instance, here (within the scope of this book) the MFC the Object is to have a specific meaning, refers to the package of Windows Object C + + Object does not refer to any C + + the Object. MFC Object and Windows Object is not the same, but the two closely linked. Window object, for example: an MFC window object is a C + + CWnd class (or derived class) instance, is a program created directly. Program execution with the window class constructor call generation, disappear with the call to t he destructor. Windows window is an instance of an internal data structure of the Windows system from a window handle identifies the Windows system to create it and give it to allocate system resources. Windows window after the MFC window object is created by the Create member function of CWnd class to create a window handle is stored in the window object's m_hWnd member variable. Windows window can be destroyed, a program can also be destroyed by the actions of users. MFC window objects and Windows window object relationship shown in Figure 2-1. the other Windows Object and the corresponding MFC Object also has a similar relationship.MFC window class CWndOn Windows systems, the attributes of a window in two places to store: one part on the inside of the window class ", as described above is specified in the login window; another part on the Windows Object, such as: the size of the window, the window position (X, Y axis), the window Z-order of the state of the window (ACTIVE, MINIMIZED, MAXMIZED, RESTORED ...), and other window (parent window, child window ...), the window can receive keyboard or mouse message and so on.In order to express the commonality of all these windows, the MFC design a window base class of the CWnd. It is very important, CWnd to provide a standard generic MFC window procedure, all windows in MFC use this window. As for the common window procedure was able to achieve different operation for each window, that the mysteries of the MFC message mapping mechanism and role of theCreate a window object in MFCMFC to create a window object in two steps, first create an MFC window object, and then create a corresponding Windows window. Memory use, the MFC window object on the stack or heap (new creation) to create. The specific formulation is as follows:Create an MFC window object. By the definition of a CWnd or its derived class instance variables or dynamically create an MFC window instance, the former stack space to create an MFC window objects, which create an MFC window objects in the heap space.Calls the appropriate window to create a function to create a Windows window object.The use of the MFC windowMFC provides a window class, its function and purpose vary. The programmer should choose which classes to use, and how to use them?Direct use of the MFC provides a window class, or start with the MFC window class derived a new C + + class and then use it under normal circumstances, these do not require the programmer to provide the registration code of the window. Need to derive the new C + + class, as the MFC window class is already able to meet the requirements. Derived C + + class inherits the characteristics of the base class and to change or extend its functionality, such as increasing or change the news, events, special processing.The main use or inherit the following MFC window class (the hierarchy shown in Figure 1-1):Framework class CFrameWnd, CMdiFrameWnd;Document framework CMdiChildWnd;View CView, and CView derived view of the special features such as: list CListView edit CEditView tree list CTreeView, RTF CRichEditView the dialog-based CFormView and so on.Dialog box, the CDialog.Typically, the window must be from the framework of the application of these classes are derived and depending on the window or dialog box.Toolbar CToolBarStatus bar CStatusBarOther types of control window, such as CList of the list box, the CEdit of the edit box, combo box the CComboBox button Cbutton.Typically, the direct use of these classes.The destruction of the window in MFCThe window object after use, should be destroyed. MFC, a window object is the destruction of the destruction including the destruction of the HWND of the window object and MFC window object. Under normal circumstances, MFC programming framework automatically handle these.(1) of CFrameWnd and CView derived classThe closure of these windows lead to the destruction of the window function DestroyWindow is called. Windows window is destroyed, the last member function is called by the MFC framework the OnNcDestroy function, which is responsible for the Windows clean-up work, and the last call virtual member function of the PostNcDestroy. CFrameWnd and CView, PostNcDestroy call delete this delete their own MFC window object.Therefore, these windows, as mentioned above, should be in the heap (Heap) is allocated, but, do not use the delete operations on these objects.(2) for Windows Control windowIn their destructor will be called DestroyWidnow to destroy the window. If such a window object allocated on the stack beyond the scope of the destructor call, the MFC window object and its Windows window object is destroyed. If the heap (Heap) is allocated, then explicitly call delete operator, resulting in the destruction of the destructor calls and window.Therefore, this type of window should be allocated on the stack, to avoid the extra code to destroy the window. As mentioned earlier the CMainFrame member variables m_wndStatusBar and m_wndToolBar is one such example.(3) For programmers directly derived from CWnd windowProgrammers can be implemented in a derived class to one of these two mechanisms, and then, in the corresponding specification.Device descriptor table summarizes theWhen an application uses GDI functions, you must first load a specific device driver, and then draw the window device context, such as the specified line width and color, brush styles and colors, fonts, clipping region. Unlike other Win32 structure, equipment description table can not be accessed directly, only indirectly through a series of Win32 function operation.中文译文:Microsoft Visual C++ 6.0 和MFC简要介绍Visual C ++ 6.0,简称VC或者VC6.0,是微软推出的一款C 编译器,将“高级语言”翻译为“机器语言(低级语言)”的程序。
外文资料Object landscapes and lifetimesTechnically, OOP is just about abstract data typing, inheritance, and polymorphism, but other issues can be at least as important. The remainder of this section will cover these issues.One of the most important factors is the way objects are created and destroyed. Where is the data for an object and how is the lifetime of the object controlled? There are different philosophies at work here. C++ takes the approach that control of efficiency is the most important issue, so it gives the programmer a choice. For maximum run-time speed, the storage and lifetime can be determined while the program is being written, by placing the objects on the stack (these are sometimes called automatic or scoped variables) or in the static storage area. This places a priority on the speed of storage allocation and release, and control of these can be very valuable in some situations. However, you sacrifice flexibility because you must know the exact quantity, lifetime, and type of objects while you're writing the program. If you are trying to solve a more general problem such as computer-aided design, warehouse management, or air-traffic control, this is too restrictive.The second approach is to create objects dynamically in a pool of memory called the heap. In this approach, you don't know until run-time how many objects you need, what their lifetime is, or what their exact type is. Those are determined at the spur of the moment while the program is running. If you need a new object, you simply make it on the heap at the point that you need it. Because the storage is managed dynamically, at run-time, the amount of time required to allocate storage on the heap is significantly longer than the time to create storage on the stack. (Creating storage on the stack is often a single assembly instruction tomove the stack pointer down, and another to move it back up.) The dynamic approach makes the generally logical assumption that objects tend to be complicated, so the extra overhead of finding storage and releasing that storage will not have an important impact on the creation of an object. In addition, the greater flexibility is essential to solve the general programming problem.Java uses the second approach, exclusively]. Every time you want to create an object, you use the new keyword to build a dynamic instance of that object.There's another issue, however, and that's the lifetime of an object. With languages that allow objects to be created on the stack, the compiler determines how long the object lasts and can automatically destroy it. However, if you create it on the heap the compiler has no knowledge of its lifetime. In a language like C++, you must determine programmatically when to destroy the object, which can lead to memory leaks if you don’t do it correctly (and this is a common problem in C++ programs). Java provides a feature called a garbage collector that automatically discovers when an object is no longer in use and destroys it. A garbage collector is much more convenient because it reduces the number of issues that you must track and the code you must write. More important, the garbage collector provides a much higher level of insurance against the insidious problem of memory leaks (which has brought many a C++ project to its knees).The rest of this section looks at additional factors concerning object lifetimes and landscapes.1 Collections and iteratorsIf you don’t know how many objects you’re going to need to solve a particular problem, or how long they will last, you also don’t know how to store those objects. How can you know how much space to create for thoseobjects? You can’t, since that information isn’t known until run-time.The solution to most problems in object-oriented design seems flippant: you create another type of object. The new type of object that solves this particular problem holds references to other objects. Of course, you can do the same thing with an array, which is available in most languages. But there’s more. This new object, generally called a container(also called a collection, but the Java library uses that term in a different sense so this book will use “container”), will expand itself whenever necessary to accommodate everything you place inside it. So you don’t need to know how manyobjects you’re going to hold in a container. Just create a container object and let it take care of the details.Fortunately, a good OOP language comes with a set of containers as part of the package. In C++, it’s part of the Standard C++ Library and is sometimes called the Standard Template Library (STL). Object Pascal has containers in its Visual Component Library (VCL). Smalltalk has a very complete set of containers. Java also has containers in its standard library. In some libraries, a generic container is considered good enough for all needs, and in others (Java, for example) the library has different types of containers for different needs: a vector (called an ArrayListin Java) for consistent access to all elements, and a linked list for consistent insertion at all elements, for example, so you can choose the particular type that fits your needs. Container libraries may also include sets, queues, hash tables, trees, stacks, etc.All containers have some way to put things in and get things out; there are usually functions to add elements to a container, and others to fetch those elements back out. But fetching elements can be more problematic, because a single-selection function is restrictive. What if you want to manipulate or compare a set of elements in the container instead of just one?The solution is an iterator, which is an object whose job is to select the elements within a container and present them to the user of the iterator. As a class, it also provides a level of abstraction. This abstraction can be used to separate the details of the container from the code that’s accessing that container. The container, via the iterator, is abstracted to be simply a sequence. The iterator allows you to traverse that sequence without worrying about the underlying structure—that is, whether it’s an ArrayList, a LinkedList, a Stack, or something else. This gives you the flexibility to easily change the underlying data structure without disturbing the code in your program. Java began (in version 1.0 and 1.1) with a standard iterator, called Enumeration, for all of its container classes. Java 2 has added a much more complete container library that contains an iterator called Iterator that does more than the older Enumeration.From a design standpoint, all you really want is a sequence that can be manipulated to solve your problem. If a single type of sequence satisfied all of your needs, there’d be no reason to have different kinds. There are two reasons that you need a choice of containers. First, containers provide different types of interfaces and external behavior.A stack has a different interface and behavior than that of a queue, which is different from that of a set or a list. One of these might provide a more flexible solution to your problem than the other. Second, different containers have different efficiencies for certain operations. The best example is an ArrayList and a LinkedList. Both are simple sequences that can have identical interfaces and external behaviors. But certain operations can have radically different costs. Randomly accessing elements in an ArrayList is a constant-time operation; it takes the same amount of time regardless of the element you select. However, in a LinkedList it is expensive to move through the list to randomly selectan element, and it takes longer to find an element that is further down the list. On the other hand, if you want to insert an element in the middle of a sequence, it’s much cheaper in a LinkedList than in an ArrayList. These and other operations have different efficiencies depending on the underlying structure of the sequence. In the design phase, you might start with a LinkedList and, when tuning for performance, change to an ArrayList. Because of the abstraction via iterators, you can change from one to the other with minimal impact on your code.In the end, remember that a container is only a storage cabinet to put objects in. If that cabinet solves all of your needs, it doesn’t really matter how it is implemented (a basic concept with most types of objects). If you’re working in a programming environment that has built-in overhead due to other factors, then the cost difference between an ArrayList and a LinkedList might not matter. You might need only one type of sequence. You can even imagine the “perfect”container abstraction, which can automatically change its underlying implementation according to the way it is used.2 The singly rooted hierarchyOne of the issues in OOP that has become especially prominent since the introduction of C++ is whether all classes should ultimately be inherited from a single base class. In Java (as with virtually all other OOP languages) the answer is “yes”and the name of this ultimate base class is simply Object. It turns out that the benefits of the singly rooted hierarchy are many.All objects in a singly rooted hierarchy have an interface in common, so they are all ultimately the same type. The alternative (provided by C++) is that you don’t know that everything is the same fundamental type. From a backward-compatibility standpoint this fits the model of C better and can be thought of as less restrictive, but when you want to do full-onobject-oriented programming you must then build your own hierarchy to provide the same convenience that’s built into other OOP languages. And in any new class library you acquire, some other incompatible interface will be used. It requires effort (and possibly multiple inheritance) to work the new interface into your design. Is the extra “flexibility” of C++ worth it? If you need it—if you have a large investment in C—it’s quite valuable. If you’re starting from scratch, other alternatives such as Java can often be more productive.All objects in a singly rooted hierarchy (such as Java provides) can be guaranteed to have certain functionality. You know you can perform certain basic operations on every object in your system. A singly rooted hierarchy, along with creating all objects on the heap, greatly simplifies argument passing (one of the more complex topics in C++).A singly rooted hierarchy makes it much easier to implement a garbage collector (which is conveniently built into Java). The necessary support can be installed in the base class, and the garbage collector can thus send the appropriate messages to every object in the system. Without a singly rooted hierarchy and a system to manipulate an object via a reference, it is difficult to implement a garbage collector.Since run-time type information is guaranteed to be in all objects, you’ll never end up with an object whose type you cannot determine. This is especially important with system level operations, such as exception handling, and to allow greater flexibility in programming.3 Collection libraries and support for easy collection useBecause a container is a tool that you’ll use frequently, it makes sense to have a library of containers that are built in a reusable fashion, so you can take one off the shelf Because a container is a tool that you’ll use frequently, it makes sense to have a library of containers that are built in a reusable fashion, so you can take one off the shelf and plugit into your program. Java provides such a library, which should satisfy most needs.Downcasting vs. templates/genericsTo make these containers reusable, they hold the one universal type in Java that was previously mentioned: Object. The singly rooted hierarchy means that everything is an Object, so a container that holds Objects can hold anything. This makes containers easy to reuse.To use such a container, you simply add object references to it, and later ask for them back. But, since the container holds only Objects, when you add your object reference into the container it is upcast to Object, thus losing its identity. When you fetch it back, you get an Object reference, and not a reference to the type that you put in. So how do you turn it back into something that has the useful interface of the object that you put into the container?Here, the cast is used again, but this time you’re not casting up the inheritance hierarchy to a more general type, you cast down the hierarchy to a more specific type. This manner of casting is called downcasting. With upcasting, you know, for example, that a Circle is a type of Shape so it’s safe to upcast, but you don’t know that an Object is necessarily a Circle or a Shape so it’s hardly safe to downcast unless you know that’s what you’re dealing with.It’s not completely dangerous, however, because if you downcast to the wrong thing you’ll get a run-time error called an exception, which will be described shortly. When you fetch object references from a container, though, you must have some way to remember exactly what they are so you can perform a proper downcast.Downcasting and the run-time checks require extra time for the runningprogram, and extra effort from the programmer. Wouldn’t it make sense to somehow create the container so that it knows the types that it holds, eliminating the need for the downcast and a possible mistake? The solution is parameterized types, which are classes that the compiler can automatically customize to work with particular types. For example, with a parameterized container, the compiler could customize that container so that it would accept only Shapes and fetch only Shapes.Parameterized types are an important part of C++, partly because C++ has no singly rooted hierarchy. In C++, the keyword that implements parameterized types is “template.” Java currently has no parameterized types since it is possible for it to get by—however awkwardly—using the singly rooted hierarchy. However, a current proposal for parameterized types uses a syntax that is strikingly similar to C++ templates.译文对象的创建和存在时间从技术角度说,OOP(面向对象程序设计)只是涉及抽象的数据类型、继承以及多形性,但另一些问题也可能显得非常重要。
XXXX大学本科毕业设计(论文)外文翻译原文:How Visual Studio .NET Generates SQL Statements forConcurrency ControlAuthor: Steve SteinVisual Studio TeamAbstract: This paper examines the SQL statements Visual Studio® .NET generates for different kinds of concurrency control, how to modify them for better performance, and how to generate a statement that does not use concurrency control. (5 printed pages).IntroductionAny application that might have multiple users simultaneously attempting to access and modify data needs some form of concurrency control. Otherwise, one user's changes could inadvertently overwrite modifications from other users. The design tools in Visual Studio .NET can create SQL statements that use the "check all values" approach to optimistic concurrency or the "last-in wins" approach to updating data. This paper will explain:∙How each of these statement types are generated.∙How to modify the generated SQL statement for better performance.PrerequisitesYou should have an understanding of:∙Fundamental data concepts, including datasets and data adapters. For more information, see Introduction to Data Access with .∙Concurrency control basics and the options available in Visual Studio .NET. For more information, see Introduction to Data Concurrency in .Where Are the SQL Statements?SQL statements are located in the CommandText property of command objects. SQL commands are automatically generated at design time when configuring data adapters, and at run time when using command builder objects. For more information, see Concurrency and Command BuilderObjets .before us have addressed overlay network programming issues. Even early overlay network Configuring Data Adapters∙Drag a data adapter from the Data tab of the Toolbox∙Drag a table from Server Explorer∙Modifying an existing adapter, by selecting a data adapter and clicking the Configure Data Adapter link at the bottom of the Properties window.Command Builder objects∙Command builder objects are created programmatically at run time. For more information, see (SqlCommandBuilder or OleDbCommandBuilder)Concurrency and Data AdaptersWhen configuring data adapters with the Data Adapter Configuration Wizard, you can decide whether to use optimistic concurrency for the generated Update and Delete statements.Considerations and Caveats∙Your data source must have a primary key in order for the SQL statements to be generated to use optimistic concurrency.∙When creating data adapters by dragging tables from Server Explorer, the data adapter creates Update and Delete statements that are automatically configured for optimisticconcurrency. If you do not want to use optimistic concurrency, you can reconfigure the dataadapter: Right-click the adapter and select Configure Data Adapter from the shortcut menu,then clear the Use optimistic concurrency option of the Advanced SQL Generation OptionsDialog Box. The wizard will recreate the statements without the additional code to check forconcurrency violations.∙When reconfiguring an existing data adapter, note that the advanced settings all revert to their default state. For example, if you cleared the Use optimistic concurrency option when theadapter was originally configured, it will automatically be selected if you reconfigure it, even if you do not access the Advanced SQL Generation Options dialog box.∙If you select the Use existing stored procedures option in the Choose a Query Type section of the Data Adapter Configuration Wizard, the option to use optimistic concurrency is notavailable. The stored procedures will execute as is, and any desired concurrency checkingmust be done within the stored procedure, or programmatically built into your application.。
.NET和C#简介为了理解.NET的重要性,考虑一下近10年来出现的许多Windows技术的本质会有一定的帮助。
尽管所有的Windows操作系统在表面上看来完全不同,但从Windows 3.1(1992年)到Windows Server 2003,在内核上都有相同的Windows API。
在我们转而使用Windows的新版本时,API中增加了非常多的新功能,但这是一个演化和扩展API的过程,并非是替换它。
向后兼容性是Windows技术的极其重要的特性,也是Windows平台的一个长处,但它有一个很大的缺点。
每次某项技术进行演化,增加了新功能后,都会比它以前更复杂。
很明显,对此必须进行改进。
Microsoft不可能一直扩展这些开发工具和语言,使它们越来越复杂,既要保证能跟上最新硬件的发展步伐,又要与20世纪90年代初开始流行的Windows产品向后兼容。
如果要得到一种简单而专业化的语言、环境和开发工具,让开发人员轻松地编写优秀的软件,就需要一种新的开端。
这就是C#和.NET的作用。
粗略地说,.NET是一种在Windows上编程的新架构——一种新API。
C#是一种新语言,它可以利用.NET Framework及其开发环境中的所有新特性,以及在最近20年来出现的面向对象的编程方法。
在继续介绍前,必须先说明,向后兼容性并没有在这个演化进程中失去。
现有的程序仍可以使用,.NET也兼容现有的软件。
软件组件在Windows上的通信,现在几乎都是使用COM实现的。
因此,.NET能够提供现有COM组件的包装器(wrapper),以便.NET组件与之通信。
Microsoft已经扩展了C++,提供了一种新语言J#,还对VB进行了很多改进,把它转变成为功能更强大的,并允许把用这些语言编写的代码用于.NET环境。
但这些语言都因有多年演化的痕迹,所以不能完全用现在的技术来编写。
在使用.NET Framework 1.0和Visual Studio .NET 2002时,要创建可移动应用程序,就必须下载Microsoft Mobile Internet Toolkit(MMIT)。
计算机专业毕业设计外文翻译Visual C++ MFC 简要介绍工学部工学一部专业计算机科学与技术班级学号姓名指导教师负责教师2008年7月Introduction to MFC Programming with Visual C++ Version 6.xby Marshall BrainVisual C++ is much more than a compiler. It is a complete 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 compatible 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, compile, 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?Let'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 time-honored 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 Windowsplatform, 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 Window's API Reference books. For Window's NT, the API is typically referred to as the "Win32 API," to distinguish it from the original 16-bit API of lower-level Windows products like Windows 3.1.Microsoft also provides a C++ library that sits on top of any of the Windows APIs and makes the programmer's job easier. Called the Microsoft Foundation Class library (MFC), this library'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 3.1 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 example, if the user clicks a button, you want to have code in place that responds appropriately. It is this sort of event-handling code that will form the bulk of any application. Once the application responds correctly to all of the available controls, it is finished.You can see from this discussion that the creation of a Windows program is a straightforward process when using MFC. The goal of these tutorials is to fill in the details and to show the techniques you can use to create professional applications as quickly as possible. The Visual C++ application development environment is specifically tuned to MFC, so by learning MFC and Visual C++ together you can significantly increase your power as an application developer.Windows V ocabularyThe vocabulary used to talk about user interface features and software development in Windows is basic but unique. Here we review a few definitions to make discussion easier for those who are new to the environment.Windows applications use several standard user controls:Static text labelsPush buttonsList boxesCombo boxes (a more advanced form of list)Radio boxesCheck boxesEditable text areas (single and multi-line)Scroll barsYou can create these controls either in code or through a "resource editor" that can create dialogs and the controls inside of them. In this set of tutorials we will examine how to create them in code. See the tutorials on the AppWizard and ClassWizard for an introduction to the resource editor for dialogs.Windows supports several types of application windows. A typical application will live inside a "frame window". A frame window is a fully featured main window that the user can re-size, minimize, maximize to fill the screen, and so on. Windows also supports two types of dialog boxes: modal and modeless. A modal dialog box, once on the screen, blocks input to the rest of the application until it is answered. A modeless dialog box can appear at the same time as the application and seems to "float above" it to keep from being overlaid.Most simple Windows applications use a Single Document Interface, or SDI, frame. The Clock, PIF editor, and Notepad are examples of SDI applications. Windows also provides an organizing scheme called the Multiple Document Interface, or MDI for more complicated applications. The MDI system allows the user to view multiple documents at the same time within a single instance of an application. For example, a text editor might allow the user to open multiple files simultaneously. When implemented with MDI, the application presents a large application window that can hold multiple sub-windows, each containing a document. The single main menu is held by the main application window and it applies to the top-most window held within the MDI frame. Individual windows can be iconified or expanded as desired within the MDI frame, or the entire MDI frame can be minimized into a single icon on the desktop. The MDI interface gives the impression of a second desktop out on the desktop, and it goes a long way towards organizing and removing window clutter.Each application that you create will use its own unique set of controls, its own menu structure, and its own dialog boxes. A great deal of the effort that goes into creating anygood application interface lies in the choice and organization of these interface objects. Visual C++, along with its resource editors, makes the creation and customization of these interface objects extremely easy.Event-driven Software and V ocabularyAll window-based GUIs contain the same basic elements and all operate in the same way. On screen the user sees a group of windows, each of which contains controls, icons, objects and such that are manipulated with the mouse or the keyboard. The interface objects seen by the user are the same from system to system: push buttons, scroll bars, icons, dialog boxes, pull down menus, etc. These interface objects all work the same way, although some have minor differences in their "look and feel." For example, scroll bars look slightly different as you move from Windows to the Mac to Motif, but they all do the same thing.From a programmer'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 un-editable text area, and let the user exit the program by clicking on a push-button labeled "quit".As the user manipulates the application's controls, the program must respond appropriately. The responses are determined by the user's actions on the different controls using the mouse and the keyboard. Each user interface object on the screen will respond to events differently. For example, if the user clicks the Quit button, the button must update the screen appropriately, highlighting itself as necessary. Then the program must respond by quitting. Normally the button manages its appearance itself, and the program in some way receives a message from the button that says, "The quit button was pressed. Do something about it." The program responds by exiting.Windows follows this same general pattern. In a typical application you will create a main window and place inside it different user interface controls. These controls are often referred to as child windows-each control is like a smaller and more specialized sub-window inside the main application window. As the application programmer, youmanipulate the controls by sending messages via function calls, and they respond to user actions by sending messages back to your code.If you have never done any "event-driven" programming, then all of this may seem foreign to you. However, the event-driven style of programming is easy to understand. The exact details depend on the system and the level at which you are interfacing with it, but the basic concepts are similar. In an event-driven interface, the application paints several (or many) user interface objects such as buttons, text areas, and menus onto the screen. Now the application waits-typically in a piece of code called an event loop-for the user to do something. The user can do anything to any of the objects on screen using either the mouse or the keyboard. The user might click one of the buttons, for example. The mouse click is called an event. Event driven systems define events for user actions such as mouse clicks and keystrokes, as well as for system activities such as screen updating.At the lowest level of abstraction, you have to respond to each event in a fair amount of detail. This is the case when you are writing normal C code directly to the API. In such a scenario, you receive the mouse-click event in some sort of structure. Code in your event loop looks at different fields in the structure, determines which user interface object was affected, perhaps highlights the object in some way to give the user visual feedback, and then performs the appropriate action for that object and event. When there are many objects on the screen the application becomes very 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 low-level 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 pre-arranged 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 ExampleOne of the best ways to begin understanding the structure and style of a typical MFC program is to enter, compile, and run a small example. The listing below contains a simple "hello world" program. If this is the first time you've seen this sort of program, it probablywill not make a lot of sense initially. Don't worry about that. We will examine the code in detail in the next tutorial. For now, the goal is to use the Visual C++ environment to create, compile and execute this simple program.//hello.cpp#include <afxwin.h>// Declare the application classclass CHelloApp : public CWinApp{public:virtual BOOL InitInstance();};// Create an instance of the application classCHelloApp HelloApp;// Declare the main window classclass CHelloWindow : public CFrameWnd{CStatic* cs;public:CHelloWindow();};// The InitInstance function is called each// time the application first executes.BOOL CHelloApp::InitInstance(){m_pMainWnd = new CHelloWindow();m_pMainWnd->ShowWindow(m_nCmdShow);m_pMainWnd->UpdateWindow();return TRUE;}// The constructor for the window classCHelloWindow::CHelloWindow(){// Create the window itselfCreate(NULL,"Hello World!",WS_OVERLAPPEDWINDOW,CRect(0,0,200,200));// Create a static labelcs = new CStatic();cs->Create("hello world",WS_CHILD|WS_VISIBLE|SS_CENTER,CRect(50,80,150,150),this);}This small program does three things. First, it creates an "application object." Every MFC program you write will have a single application object that handles the initialization details of MFC and Windows. Next, the application creates a single window on the screen to act as the main application window. Finally, inside that window the application creates a single static text label containing the words "hello world". We will look at this program in detail in the next tutorial to gain a complete understanding of its structure.The steps necessary to enter and compile this program are straightforward. If you have not yet installed Visual C++ on your machine, do so now. You will have the option of creating standard and custom installations. For the purposes of these tutorials a standard installation is suitable and after answering two or three simple questions the rest of the installation is quick and painless.Start VC++ by double clicking on its icon in the Visual C++ group of the Program Manager. If you have just installed the product, you will see an empty window with a menu bar. If VC++ has been used before on this machine, it is possible for it to come up in several different states because VC++ remembers and automatically reopens the project and files in use the last time it exited. What we want right now is a state where it has no project or code loaded. If the program starts with a dialog that says it was unable to find a certain file, clear the dialog by clicking the "No" button. Go to the Window menu and select the Close All option if it is available. Go to the File menu and select the Close option if it is available to close any remaining windows. Now you are at the proper starting point.If you have just installed the package, you will see a window that looks something like this:This screen can be rather intimidating the first time you see it. To eliminate some ofthe intimidation, click on the lower of the two "x" buttons () that you see in the upper right hand corner of the screen if it is available. This action will let you close the "InfoViewer Topic" window. If you want to get rid of the InfoViewer toolbar as well, you can drag it so it docks somewhere along the side of the window, or close it and later get it back by choosing the Customize option in the Tools menu.What you see now is "normal". Along the top is the menu bar and several toolbars. Along the left side are all of the topics available from the on-line book collection (you might want to explore by double clicking on several of the items you see there - the collection of information found in the on-line books is gigantic). Along the bottom is a status window where various messages will be displayed.Now what? What you would like to do is type in the above program, compile it and run it. Before you start, switch to the File Manager (or the MS-DOS prompt) and make sure your drive has at least five megabytes of free space available. Then take the following steps.Creating a Project and Compiling the CodeIn order to compile any code in Visual C++, you have to create a project. With a very small program like this the project seems like overkill, but in any real program the projectconcept is quite useful. A project holds three different types of information: It remembers all of the source code files that combine together to create one executable. In this simple example, the file HELLO.CPP will be the only source file, but in larger applications you often break the code up into several different files to make it easier to understand (and also to make it possible for several people to work on it simultaneously). The project maintains a list of the different source files and compiles all of them as necessary each time you want to create a new executable.It remembers compiler and linker options particular to this specific application. For example, it remembers which libraries to link into the executable, whether or not you want to use pre-compiled headers, and so on.It remembers what type of project you wish to build: a console application, a windows application, etc.If you are familiar with makefiles, then it is easy to think of a project as a machine-generated makefile that has a very easy-to-understand user interface to manipulate it. For now we will create a very simple project file and use it to compile HELLO.CPP.To create a new project for HELLO.CPP, choose the New option in the File menu. Under the Projects tab, highlight Win32 Application. In the Location field type an appropriate path name or click the Browse button. Type the word "hello" in for the project name, and you will see that word echoed in the Location field as well. Click the OK button. In the next window, use the default selection "An empty project", click "Finish", then click "OK" once more in the next window. Notice there is an option for the typical "Hello World" application, however it skips a few important steps you are about to take. Visual C++ will create a new subdirectory named HELLO and place the project files named HELLO.OPT, HELLO.NCB, HELLO.DSP, and HELLO.DSW in that directory. If you quit and later want to reopen the project, double-click on HELLO.DSW.The area along the left side of the screen will now change so that three tabs are available. The InfoView tab is still there, but there is now also a ClassView and a FileView tab. The ClassView tab will show you a list of all of the classes in your application and the FileView tab gives you a list of all of the files in the project.Now it is time to type in the code for the program. In the File menu select the New option to create a new editor window. In the dialog that appears, make sure the Files tab isactive and request a "C++ Source File". Make sure the "Add to Project" option is checked for Project "hello", and enter "hello" for "File name". Visual C++ comes with its own intelligent C++ editor, and you will use it to enter the program shown above. Type (copy/paste) the code in the listing into the editor window. You will find that the editor automatically colors different pieces of text such as comments, key words, string literals, and so on. If you want to change the colors or turn the coloring off, go to the Options option in the Tools menu, choose the Format tab and select the Source Windows option from the left hand list. If there is some aspect of the editor that displeases you, you may be able to change it using the Editor tab of the Options dialog.After you have finished entering the code, save the file by selecting the Save option in the File menu. Save it to a file named HELLO.CPP in the new directory Visual C++ created.In the area on the left side of the screen, click the FileView tab and expand the tree on the icon labeled "hello files", then expand the tree on the folder icon labeled "Source Files". You will see the file named HELLO.CPP. Click on the ClassView tab and expand the "hello classes" tree and you will see the classes in the application. You can remove a file from a project at any time by going to the FileView, clicking the file, and pressing the delete button.Finally, you must now tell the project to use the MFC library. If you omit this step the project will not link properly, and the error messages that the linker produces will not help one bit. Choose the Settings option in the Project menu. Make sure that the General tab is selected in the tab at the top of the dialog that appears. In the Microsoft Foundation Classes combo box, choose the third option: "Use MFC in a Shared DLL." Then close the dialog.Having created the project file and adjusted the settings, you are ready to compile the HELLO.CPP program. In the Build menu you will find three different compile options: Compile HELLO.CPP (only available if the text window for HELLO.CPP has focus) Build HELLO.EXERebuild AllThe first option simply compiles the source file listed and forms the object file for it. This option does not perform a link, so it is useful only for quickly compiling a file to check for errors. The second option compiles all of the source files in the project that have been modified since the last build, and then links them to form an executable. The thirdoption recompiles all of the source files in the project and relinks them. It is a "compile and link from scratch" option that is useful after you change certain compiler options or move to a different platform.In this case, choose the Build HELLO.EXE option in the Build menu to compile and link the code. Visual C++ will create a new subdirectory named Debug and place the executable named HELLO.EXE in that new subdirectory. This subdirectory holds all disposable (easily recreated) files generated by the compiler, so you can delete this directory when you run short on disk space without fear of losing anything important.If you see compiler errors, simply double click on the error message in the output window. The editor will take you to that error. Compare your code against the code above and fix the problem. If you see a mass of linker errors, it probably means that you specified the project type incorrectly in the dialog used to create the project. You may want to simply delete your new directory and recreate it again following the instructions given above exactly.To execute the program, choose the Execute HELLO.EXE option in the Build menu.A window appears with the words "hello world". The window itself has the usual decorations: a title bar, re-size areas, minimize and maximize buttons, and so on. Inside the window is a static label displaying the words "hello world". Note that the program is complete. You can move the window, re-size it, minimize it, and cover and uncover it with other windows. With a very small amount of code you have created a complete Window application. This is one of the many advantages of using MFC. All the details are handled elsewhere.Visual C++ MFC 简要介绍原著:Marshall Brain Visual C++ 不仅仅是一个编译器。
毕业设计(论文)外文文献翻译文献、资料中文题目:Visual C++ MFC 简要介绍文献、资料英文题目:文献、资料来源:文献、资料发表(出版)日期:院(部):专业:班级:姓名:学号:指导教师:翻译日期: 2017.02.14Introduction to MFC Programming with Visual C++ Version 6.xby Marshall Brain Visual C++ is much more than a compiler. It is a complete 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 compatible 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, compile, 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?Let'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 time-honored 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 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 Window's API Reference books. For Window's NT, the API is typically referred to as the "Win32 API," to distinguish it from the original 16-bit API of lower-level Windows products like Windows 3.1.Microsoft also provides a C++ library that sits on top of any of the Windows APIs and makes the programmer's job easier. Called the Microsoft Foundation Class library (MFC), this library'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 3.1 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 example, if the user clicks a button, you want to have code in place that responds appropriately. It is this sort of event-handling code that will form the bulk of any application. Once the application responds correctly to all of the available controls, it is finished.You can see from this discussion that the creation of a Windows program is a straightforward process when using MFC. The goal of these tutorials is to fill in the details and to show the techniques you can use to create professional applications as quickly as possible. The Visual C++ application development environment is specifically tuned to MFC, so by learning MFC and Visual C++ together you can significantly increase your power as an application developer.Windows VocabularyThe vocabulary used to talk about user interface features and software development in Windows is basic but unique. Here we review a few definitions to make discussion easier for those who are new to the environment.Windows applications use several standard user controls:Static text labelsPush buttonsList boxesCombo boxes (a more advanced form of list)Radio boxesCheck boxesEditable text areas (single and multi-line)Scroll barsYou can create these controls either in code or through a "resource editor" that can create dialogs and the controls inside of them. In this set of tutorials we will examine how to create them in code. See the tutorials on the AppWizard and ClassWizard for an introduction to the resource editor for dialogs.Windows supports several types of application windows. A typical application will live inside a "frame window". A frame window is a fully featured main window that the user can re-size, minimize, maximize to fill the screen, and so on. Windows also supports two types of dialog boxes: modal and modeless. A modal dialog box, once on the screen, blocks input to the rest of the application until it is answered. A modeless dialog box can appear at the same time as the application and seems to "float above" it to keep from being overlaid.Most simple Windows applications use a Single Document Interface, or SDI, frame. TheClock, PIF editor, and Notepad are examples of SDI applications. Windows also provides an organizing scheme called the Multiple Document Interface, or MDI for more complicated applications. The MDI system allows the user to view multiple documents at the same time within a single instance of an application. For example, a text editor might allow the user to open multiple files simultaneously. When implemented with MDI, the application presents a large application window that can hold multiple sub-windows, each containing a document. The single main menu is held by the main application window and it applies to the top-most window held within the MDI frame. Individual windows can be iconified or expanded as desired within the MDI frame, or the entire MDI frame can be minimized into a single icon on the desktop. The MDI interface gives the impression of a second desktop out on the desktop, and it goes a long way towards organizing and removing window clutter.Each application that you create will use its own unique set of controls, its own menu structure, and its own dialog boxes. A great deal of the effort that goes into creating any good application interface lies in the choice and organization of these interface objects. Visual C++, along with its resource editors, makes the creation and customization of these interface objects extremely easy.Event-driven Software and V ocabularyAll window-based GUIs contain the same basic elements and all operate in the same way. On screen the user sees a group of windows, each of which contains controls, icons, objects and such that are manipulated with the mouse or the keyboard. The interface objects seen by the user are the same from system to system: push buttons, scroll bars, icons, dialog boxes, pull down menus, etc. These interface objects all work the same way, although some have minor differences in their "look and feel." For example, scroll bars look slightly different as you move from Windows to the Mac to Motif, but they all do the same thing.From a programmer'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 un-editable text area, and let the user exit the program by clicking on a push-button labeled "quit".As the user manipulates the application's controls, the program must respond appropriately. The responses are determined by the user's actions on the different controls using the mouse and the keyboard. Each user interface object on the screen will respond to events differently. For example, if the user clicks the Quit button, the button must update the screen appropriately, highlighting itself as necessary. Then the program must respond by quitting. Normally the button manages its appearance itself, and the program in some way receives a message from the buttonthat says, "The quit button was pressed. Do something about it." The program responds by exiting.Windows follows this same general pattern. In a typical application you will create a main window and place inside it different user interface controls. These controls are often referred to as child windows-each control is like a smaller and more specialized sub-window inside the main application window. As the application programmer, you manipulate the controls by sending messages via function calls, and they respond to user actions by sending messages back to your code.If you have never done any "event-driven" programming, then all of this may seem foreign to you. However, the event-driven style of programming is easy to understand. The exact details depend on the system and the level at which you are interfacing with it, but the basic concepts are similar. In an event-driven interface, the application paints several (or many) user interface objects such as buttons, text areas, and menus onto the screen. Now the application waits-typically in a piece of code called an event loop-for the user to do something. The user can do anything to any of the objects on screen using either the mouse or the keyboard. The user might click one of the buttons, for example. The mouse click is called an event. Event driven systems define events for user actions such as mouse clicks and keystrokes, as well as for system activities such as screen updating.At the lowest level of abstraction, you have to respond to each event in a fair amount of detail. This is the case when you are writing normal C code directly to the API. In such a scenario, you receive the mouse-click event in some sort of structure. Code in your event loop looks at different fields in the structure, determines which user interface object was affected, perhaps highlights the object in some way to give the user visual feedback, and then performs the appropriate action for that object and event. When there are many objects on the screen the application becomes very 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 low-level 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 pre-arranged 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 mapsAn ExampleOne of the best ways to begin understanding the structure and style of a typical MFC program is to enter, compile, and run a small example. The listing below contains a simple "hello world" program. If this is the first time you've seen this sort of program, it probably will not make a lot of sense initially. Don't worry about that. We will examine the code in detail in the nexttutorial. For now, the goal is to use the Visual C++ environment to create, compile and execute this simple program.//hello.cpp#include <afxwin.h>// Declare the application classclass CHelloApp : public CWinApp{public:virtual BOOL InitInstance();};// Create an instance of the application classCHelloApp HelloApp;// Declare the main window classclass CHelloWindow : public CFrameWnd{CStatic* cs;public:CHelloWindow();};// The InitInstance function is called each// time the application first executes.BOOL CHelloApp::InitInstance(){m_pMainWnd = new CHelloWindow();m_pMainWnd->ShowWindow(m_nCmdShow);m_pMainWnd->UpdateWindow();return TRUE;}// The constructor for the window classCHelloWindow::CHelloWindow(){// Create the window itselfCreate(NULL,"Hello World!",WS_OVERLAPPEDWINDOW,CRect(0,0,200,200));// Create a static labelcs = new CStatic();cs->Create("hello world",WS_CHILD|WS_VISIBLE|SS_CENTER,CRect(50,80,150,150),this);}This small program does three things. First, it creates an "application object." Every MFC program you write will have a single application object that handles the initialization details of MFC and Windows. Next, the application creates a single window on the screen to act as the main application window. Finally, inside that window the application creates a single static text label containing the words "hello world". We will look at this program in detail in the next tutorial to gain a complete understanding of its structure.The steps necessary to enter and compile this program are straightforward. If you have not yet installed Visual C++ on your machine, do so now. You will have the option of creating standard and custom installations. For the purposes of these tutorials a standard installation is suitable and after answering two or three simple questions the rest of the installation is quick and painless.Start VC++ by double clicking on its icon in the Visual C++ group of the Program Manager. If you have just installed the product, you will see an empty window with a menu bar. If VC++ has been used before on this machine, it is possible for it to come up in several different states because VC++ remembers and automatically reopens the project and files in use the last time it exited. What we want right now is a state where it has no project or code loaded. If the program starts with a dialog that says it was unable to find a certain file, clear the dialog by clicking the "No" button. Go to the Window menu and select the Close All option if it is available. Go to the File menu and select the Close option if it is available to close any remaining windows. Now you are at the proper starting point. If you have just installed the package, you will see a window that looks something like this:This screen can be rather intimidating the first time you see it. To eliminate some of the intimidation, click on the lower of the two "x" buttons () that you see in the upper right hand corner of the screen if it is available. This action will let you close the "InfoViewer Topic" window. If you want to get rid of the InfoViewer toolbar as well, you can drag it so it docks somewhere along the side of the window, or close it and later get it back by choosing the Customize option in the Tools menu.What you see now is "normal". Along the top is the menu bar and several toolbars. Along the left side are all of the topics available from the on-line book collection (you might want to explore by double clicking on several of the items you see there - the collection of information found in the on-line books is gigantic). Along the bottom is a status window where various messages will be displayed.Now what? What you would like to do is type in the above program, compile it and run it. Before you start, switch to the File Manager (or the MS-DOS prompt) and make sure your drive has at least five megabytes of free space available. Then take the following steps.Creating a Project and Compiling the CodeIn order to compile any code in Visual C++, you have to create a project. With a very small program like this the project seems like overkill, but in any real program the project concept is quite useful. A project holds three different types of information:It remembers all of the source code files that combine together to create one executable. In this simple example, the file HELLO.CPP will be the only source file, but in larger applications you often break the code up into several different files to make it easier to understand (and also to make it possible for several people to work on it simultaneously). The project maintains a list of the different source files and compiles all of them as necessary each time you want to create a new executable.It remembers compiler and linker options particular to this specific application. For example,it remembers which libraries to link into the executable, whether or not you want to use pre-compiled headers, and so on.It remembers what type of project you wish to build: a console application, a windows application, etc.If you are familiar with makefiles, then it is easy to think of a project as a machine-generated makefile that has a very easy-to-understand user interface to manipulate it. For now we will create a very simple project file and use it to compile HELLO.CPP.To create a new project for HELLO.CPP, choose the New option in the File menu. Under the Projects tab, highlight Win32 Application. In the Location field type an appropriate path name or click the Browse button. Type the word "hello" in for the project name, and you will see that word echoed in the Location field as well. Click the OK button. In the next window, use the default selection "An empty project", click "Finish", then click "OK" once more in the next window. Notice there is an option for the typical "Hello World" application, however it skips a few important steps you are about to take. Visual C++ will create a new subdirectory named HELLO and place the project files named HELLO.OPT, HELLO.NCB, HELLO.DSP, and HELLO.DSW in that directory. If you quit and later want to reopen the project, double-click on HELLO.DSW.The area along the left side of the screen will now change so that three tabs are available. The InfoView tab is still there, but there is now also a ClassView and a FileView tab. The ClassView tab will show you a list of all of the classes in your application and the FileView tab gives you a list of all of the files in the project.Now it is time to type in the code for the program. In the File menu select the New option to create a new editor window. In the dialog that appears, make sure the Files tab is active and request a "C++ Source File". Make sure the "Add to Project" option is checked for Project "hello", and enter "hello" for "File name". Visual C++ comes with its own intelligent C++ editor, and you will use it to enter the program shown above. Type (copy/paste) the code in the listing into the editor window. You will find that the editor automatically colors different pieces of text such as comments, key words, string literals, and so on. If you want to change the colors or turn the coloring off, go to the Options option in the Tools menu, choose the Format tab and select the Source Windows option from the left hand list. If there is some aspect of the editor that displeases you, you may be able to change it using the Editor tab of the Options dialog.After you have finished entering the code, save the file by selecting the Save option in the File menu. Save it to a file named HELLO.CPP in the new directory Visual C++ created.In the area on the left side of the screen, click the FileView tab and expand the tree on the icon labeled "hello files", then expand the tree on the folder icon labeled "Source Files". You will see the file named HELLO.CPP. Click on the ClassView tab and expand the "hello classes" tree and you will see the classes in the application. You can remove a file from a project at any time by going to the FileView, clicking the file, and pressing the delete button.Finally, you must now tell the project to use the MFC library. If you omit this step the projectwill not link properly, and the error messages that the linker produces will not help one bit. Choose the Settings option in the Project menu. Make sure that the General tab is selected in the tab at the top of the dialog that appears. In the Microsoft Foundation Classes combo box, choose the third option: "Use MFC in a Shared DLL." Then close the dialog.Having created the project file and adjusted the settings, you are ready to compile the HELLO.CPP program. In the Build menu you will find three different compile options: Compile HELLO.CPP (only available if the text window for HELLO.CPP has focus)Build HELLO.EXERebuild AllThe first option simply compiles the source file listed and forms the object file for it. This option does not perform a link, so it is useful only for quickly compiling a file to check for errors. The second option compiles all of the source files in the project that have been modified since the last build, and then links them to form an executable. The third option recompiles all of the source files in the project and relinks them. It is a "compile and link from scratch" option that is useful after you change certain compiler options or move to a different platform.In this case, choose the Build HELLO.EXE option in the Build menu to compile and link the code. Visual C++ will create a new subdirectory named Debug and place the executable named HELLO.EXE in that new subdirectory. This subdirectory holds all disposable (easily recreated) files generated by the compiler, so you can delete this directory when you run short on disk space without fear of losing anything important.If you see compiler errors, simply double click on the error message in the output window. The editor will take you to that error. Compare your code against the code above and fix the problem. If you see a mass of linker errors, it probably means that you specified the project type incorrectly in the dialog used to create the project. You may want to simply delete your new directory and recreate it again following the instructions given above exactly.To execute the program, choose the Execute HELLO.EXE option in the Build menu. A window appears with the words "hello world". The window itself has the usual decorations: a title bar, re-size areas, minimize and maximize buttons, and so on. Inside the window is a static label displaying the words "hello world". Note that the program is complete. You can move the window, re-size it, minimize it, and cover and uncover it with other windows. With a very small amount of code you have created a complete Window application. This is one of the many advantages of using MFC. All the details are handled elsewhere.Visual C++ MFC 简要介绍原著 Marshall Brain Visual C++ 不仅仅是一个编译器。
MFC Programming and C + + related technologiesMFC, Microsoft Foundation Classes (Microsoft Foundation Classes), is actually provided by Microsoft for the C + + environment for writing applications in a framework and engine, VC + + is to Windows, developers use professional C + + SDK (SDK, Standard SoftWare Develop Kit, professional software development platform), MFC is hung on it a supporting software development kit, MFC, as with the VC + + flesh and blood portion (Note C + + and VC + + differences: C + + is a programming language, is a we acknowledge the preparation of the general specification of software, and VC + + is a compiler, or a compiler + source code editor IDE, WS, PlatForm, which Pascal and Delphi's relationship with a truth, Pascal was the language of Delphi basic, Delphi Pascal specification for use under Win application development and compilation, but VB is different from the relationship between language and Basic, Basic language is developed in VB application's language has become the new norm Basic, VB newly added Basic language elements, such as the elements of object-oriented programming is a qualitative leap forward, so that both a VB IDE, and grow into a new programming language), MFC integration with BC + + VCL is a non-plug type as package, class library, but Microsoft MFC class is designed for the distribution of VC + + .. Win API and MFC is a combination of C + +, API, that Microsoft's Windows, the application programming language interface, is a software programming specifications, but is not a programming language itself, can allow users to use a variety of third parties (such as the I side, Microsoft is a party, Borland is the third party to) programming language for applications on Windows, the development of these applications were developed to run in Windows, such as VB, VC + +, Java , Delhpi essentially all of the programming language function from the API, so using them to develop applications that can work out the message in the Windows system and graphics, the compliance with Windows as an operating system's internal implementation, it is also a necessity, Microsoft If you do not provide API, this world of Windows programming job would not exist, Microsoft's product will quickly become a garbage from the fashion, the above mentioned API function, MFC is a Microsoft proprietary C + + package, which allows users to combine the one hand, Microsoft's Professional C + + SDK for Windows, application development easier, because MFC is the API package, Microsoft has done a lot of work, hiding a lot of application developers in Windows, using C + + & MFC preparation software for a large number of the section, such as the implementation of the message processing applications, equipment, environmental graphics, this combination is convenient for the purpose, we must pay the price (which is Microsoft's style has always been), and therefore created a MFC class in the package of a certain degree of redundancy and circuitous, but this is acceptable .. Finally, understand that MFC is not just a function of simple interface development system, which provides most of the classes used to interface development, associated with a window of the action, but it provides a lot of class in the class is not associated with a window that the categories The role is not an interface class does notimplement the control of a window object (such as the creation, destruction), but some in Windows (using MFC vast majority of programs written to run in Windows) to implement the internal processing of the class, such as database management etc., the study should be most time consuming is the message and the device environment, C + + and MFC to learn the most difficult part is the pointer, C + + object-oriented programming in other parts, such as data types, flow control both is not difficult, it is recommended to learn C + + version of the data structure. MFC encapsulates Microsoft's API. What does that mean? As a provider of powerful windows application programming interface to the operating system, programmers do a lot of convenience, the traditional win32 development (direct interface functions with windows API) for programmers is very difficult because, API functions too more, and the name of the mess, from zero to a window frame is easily hundreds of lines of code. MFC is the object-oriented programming and the perfect combination of Application framework, he would have been classified in the traditional API package, and created a program for you general framework MFC is Windows API package, which greatly simplifies our work; learn VC is mainly to learn MFC, there are about 100 classes, but also commonly used in twenty or thirty. Back four words should be the same as those commonly used in class get to know; of course, do not memorize, to help by looking to see examples, hands-on exercises to learn them; Moreover, not every class have to learn all the functions within, to accumulate. If you really want to be a master, to be a laptop think it is important to their classes, functions, down, ready to learn, but also a good spot method. Programming Advantages With the innovation of programming languages, MFC shortcomings become increasingly prominent. The most important entry barrier is higher relative to other languages, but also to complete a task relatively large amount of code. The original advantages, such as running speed, etc., but also because of other programming languages and personal computers continue to improve computing speed increases appear less prominent. MFC seems bad to worse. MFC is really no advantage, but it? No, the face of the underlying process, it is very easy with the combination of Windows API or driver is in your own code to use API functions directly, while the API and driver information are based on C language-based, which makes VC programmersto more easily use Windows API. This has a very interesting phenomenon, that is, when the VC started to pay more to the programmer to learn, but once mastered, the development of other areas of the program or using third-party software, such as industrial control procedures, the underlying The programs are written in C language, but rather VC programmers can quickly grasp the field of programming. And many other programming languages can not even find relevant information. This shows that VC (MFC) is actually an entry difficult, but very easy to learn the language extension framework. If only limited to one area, then VC is no advantage at all, but if you develop a new field of application or the program involves a number of application areas, it can reduce the frequency of repetition and difficulty, VC (MFC) of the benefits will immediately apparent. Language development C + + language development can be divided into three stages: The first stage, from 80 to 1995. Thisphase is basically C + + language is the traditional type of object-oriented language, and by virtue of the efficiency of close to C language, developed for use in the industrial sector accounts for a significant language share; The second phase from 1995 to 2000, this stage as the Standard Template Library (STL) and later the Boost libraries such as the emergence of generic programming in C + +, the proportion of occupied more and more sexual. Of course, the same as Java, C # and other languages and the emergence of large-scale hardware prices drop, C + + has been some impact; The third stage, from 2000 to date, due to Loki, MPL and other libraries as the representative of generative programming and template meta programming there, C + + appeared in the history and development of a new peak, and the emergence of these new technologies and the original technology integration, so that C + + has become the main programming language of the most complex one C + + Getting Started C + + is a language, merely its syntax, features, standard library already is a very advanced courses, so the time to start learning, we must first lay a solid foundation. There are a lot of the Visual C + + book, although it may take 1-2 chapters to introduce the basic characteristics of C + +, but that will not let you get started. Therefore, beginners should choose to learn C + + for C + + language itself, books, and can not be for the Visual C + +, MFC or Windows API's. Learning C + + should be easy to difficult, step by step. Often said that before learning C + + should learn C language before. In fact it is not necessary, C + + and C language, while a relationship, it is still two different languages. Of course, before learning C + + programming language to learn than others is very good. C + + that make learning faster, after all, a lot of computer language concepts are interlinked. As for the zero-based beginners, you should stop and do not become impatient. To become a master of C + + is not so easy to take great efforts. From the introductory textbook of choice, mainly to see the learner's own situation. If you have had high-level language learning experience, it is recommended that use of Transplantation and Hemopurification the "C + + programming." Note that 2004 edition, 2006 edition of the book is a castrated version, up to the object-oriented. Although C and C + + are similar, but has been said before, C and C + + should be used to learn two languages, so that the contents of 06 to a little bit lacking. Transplantation and Hemopurification 04 edition of this book is more structured, and organized is also very clear. If the basis of other high-level language, then the estimated half a year of C + + will be able to have a understanding of the profile. Transplantation and Hemopurification teacher's book has become the major institutions of higher education textbooks, are more subject to recognized. If you start from the zero-based learning C + +, it is recommended to use Pan Jiajie of "learn C + +". This book is a book in 2008, I heard a student was studying the time to write. Book online, download a free electronic version. This book is mainly for beginners, put it is also more interesting to compare those who can interest in learning. So there is no basis for the beginner This book is also a good choice, just want to quickly become the master, may be reading this book is not enough. As for the book after reading the entry, you should see some high-level book. Such as The C + + Programming Language and C + + Primer, but also able to STL, MFC, API and otherdirection. If you are interested in other languages, but also to look at C # and Java, C + + they are a lot of concepts from grammar and are similar.The design principles of C + + • C + + designed as a static type, and C as efficient and portable multi-purpose program ming language. • C + + designed to support direct and wide variety of programming styles (procedural programming, data abstraction, object-oriented programming, generic programming). • C + + is designed to give programmers more choice, even if the wrong choice could lead to program designers. • C + + designed to be compatible as possible with C, whereby a C to C + + from the smooth transition. • C + + to avoid limited or no general-purpose platform features. • C + + does not use the features will bring addi tional costs. • C + + is designed without complex programming environment.MFC 程序设计与C++相关技术MFC,微软基础类(Microsoft Foundndation Classes),实际上是微软提供的,用于在C++环境下编写应用程序的一个框架和引擎,VC++是Windows 下开发人员使用的专业C++ SDK(SDK,Standard SoftWare Develop Kit,专业软件开发平台),MFC 就是挂在它之上的一个辅助软件开发包,MFC 作为与VC++血肉相连的部分(注意C++和VC++ 的区别:C++是一种程序设计语言,是一种大家都承认的软件编制的通用规范,而VC++只是一个编译器,或者说是一种编译器+源程序编辑器的IDE,WS,PlatForm,这跟Pascal 和Delphi 的关系一个道理,Pascal 是Delphi 的语言基础,Delphi 使用Pascal 规范来进行Win 下应用程序的开发和编译,却不同于Basic 语言和VB 的关系,Basic 语言在VB 开发出来被应用的年代已经成了Basic 语言的新规范,VB 新加的Basic 语言要素,如面向对象程序设计的要素,是一种性质上的飞跃,使VB 既是一个IDE,又成长成一个新的程序设计语言),MFC 同BC++集成的VCL 一样是一个非外挂式的软件包,类库,只不过MFC 类是微软为VC++专配的.. MFC 是Win API 与C++的结合,API,即微软提供的Windows 下应用程序的编程语言接口,是一种软件编程的规范,但不是一种程序开发语言本身,可以允许用户使用各种各样的第三方(如我是一方,微软是一方,Borland 就是第三方)的编程语言来进行对Windows 下应用程序的开发,使这些被开发出来的应用程序能在Windows 下运行,比如VB,VC++,Java,Delhpi 编程语言函数本质上全部源于API,因此用它们开发出来的应用程序都能工作在Windows 的消息机制和绘图里,遵守Windows 作为一个操作系统的内部实现, 这其实也是一种必要, 微软如果不提供API, 这个世上对Windows 编程的工作就不会存在,微软的产品就会迅速从时尚变成垃圾,上面说到MFC 是微软对API 函数的专用C++封装,这种结合一方面让用户使用微软的专业C++ SDK 来进行Windows 下应用程序的开发变得容易,因为MFC 是对API 的封装,微软做了大量的工作,隐藏了好多程序开发人员在Windows 下用C++ & MFC 编制软件时的大量内节,如应用程序实现消息的处理,设备环境绘图,这种结合是以方便为目的的, 必定要付出一定代价(这是微软的一向作风),因此就造成了MFC 对类封装中的一定程度的的冗余和迂回,但这是可以接受的.. 最后要明白MFC 不只是一个功能单纯的界面开发系统,它提供的类绝大部分用来进行界面开发,关联一个窗口的动作,但它提供的类中有好多类不与一个窗口关联, 即类的作用不是一个界面类,不实现对一个窗口对象的控制(如创建,销毁),而是一些在Windows(用MFC 编写的程序绝大部分都在Windows 中运行)中实现内部处理的类,如数据库的管理类等,学习中最应花费时间的是消息和设备环境,对C++和MFC 的学习中最难的部分是指针,C++面向对象程序设计的其它部分,如数据类型,流程控制都不难,建议学习数据结构C++版。
外文文献翻译(2012届)学生姓名学号********专业班级计算机科学与技术08-5班指导教师微软Visual Studio1微软Visual StudioVisual Studio 是微软公司推出的开发环境,Visual Studio可以用来创建Windows平台下的Windows应用程序和网络应用程序,也可以用来创建网络服务、智能设备应用程序和Office 插件。
Visual Studio是一个来自微软的集成开发环境IDE(inteqrated development environment),它可以用来开发由微软视窗,视窗手机,Windows CE、.NET框架、.NET精简框架和微软的Silverlight支持的控制台和图形用户界面的应用程序以及Windows窗体应用程序,网站,Web应用程序和网络服务中的本地代码连同托管代码。
Visual Studio包含一个由智能感知和代码重构支持的代码编辑器。
集成的调试工作既作为一个源代码级调试器又可以作为一台机器级调试器。
其他内置工具包括一个窗体设计的GUI应用程序,网页设计师,类设计师,数据库架构设计师。
它有几乎各个层面的插件增强功能,包括增加对支持源代码控制系统(如Subversion和Visual SourceSafe)并添加新的工具集设计和可视化编辑器,如特定于域的语言或用于其他方面的软件开发生命周期的工具(例如Team Foundation Server的客户端:团队资源管理器)。
Visual Studio支持不同的编程语言的服务方式的语言,它允许代码编辑器和调试器(在不同程度上)支持几乎所有的编程语言,提供了一个语言特定服务的存在。
内置的语言中包括C/C + +中(通过Visual C++),(通过Visual ),C#中(通过Visual C#)和F#(作为Visual Studio 2010),为支持其他语言,如M,Python,和Ruby等,可通过安装单独的语言服务。
2012年毕业设计论文英汉互译部分Chapter 8. The IO LibraryIn C++, input/output is provided through the library. The librarydefines a family of types that support IO to and from devices such as filesand console windows. Additional types allow strings to act like files,which gives us a way to convert data to and from character forms withoutalso doing IO. Each of these IO types defines how to read and write valuesof the built-in data types. In addition, class designers generally usethe library IO facilities to read and write objects of the classes thatthey define. Class types are usually read and written using the sameoperators and conventions that the IO library defines for the built-intypes.This chapter introduces the fundamentals of the IO library. Laterchapters will cover additional capabilities: Chapter 14 will look at howwe can write our own input and output operators; Appendix A will coverways to control formatting and random access to files.Our programs have already used many IO library facilities:∙istream (input stream) type, which supports input operations∙ostream (output stream) type, which provides output operations∙cin (pronounced see-in) an istream object that reads the standard input.∙cout (pronounced see-out) an ostream object that writes to thestandard output∙cerr (pronounced see-err) an ostream object that writes to thestandard error. cerr is usually used for program error messages.∙operator >>, which is used to read input from an istream object∙operator <<, which is used to write output to an ostream object∙getline function, which takes a reference to an istream and areference to a string and reads a word from the istream into the string This chapter looks briefly at some additional IO operations, anddiscusses support for reading and writing files and strings. Appendix Acovers how to control formatting of IO operations, support for randomaccess to files, and support for unformatted IO. This primer does notdescribe the entire iostream libraryin particular, we do not cover thesystem-specific implementation details, nor do we discuss the mechanismsby which the library manages input and output buffers or how we might writeour own buffer classes. These topics are beyond the scope of this book.Instead, we'll focus on those portions of the IO library that are mostuseful in ordinary programs.8.1. An Object-Oriented LibraryThe IO types and objects we’ve used so far read and write streams of data and are used to interact with a user’s console window. Of course, real programs cannot be limited to doing IO solely to or from a console window. Programs often need to read or write named files. Moreover, it can be quite convenient to use the IO operations to format data in memory, thereby avoiding the complexity and run-time expense of reading or writing to a disk or other device. Applications also may have to read and write languages that require wide-character support.Conceptually, neither the kind of the character size affect the IO operations we want to perform. For example, we’d like to use >> to read data regardless of whether we’re reading a console window, a disk file, or an in-memory string. Similarly, we’d like to use that operator regardless of whether the characters we read fit in a char or require the wchar_t(Section2.1.1,p.34) type.At first glance, the complexities involved in supporting or using these different kinds of devices and different sized character streams might seem a daunting problem. To manage the complexity, the library uses inheritance to define a set of object-oriented classes. We'll have more to say about inheritance and object-oriented programming in Part IV, but generally speaking, types related by inheritance share a common interface. When one class inherits from another, we (usually) can use the same operations on both classes. More specifically, when two types are related by inheritance, we say that one class "inherits" the behavior the interface of its parent. In C++ we speak of the parent as the base class and the inheriting class as a derived class.The IO types are defined in three separate headers: iostream defines the types used to read and write to a console window, fstream defines the types used to read and write named files, and sstream defines the types used to read and write in-memory strings. Each of the types in fstream and sstream is derived from a corresponding type defined in the iostream header. Table 8.1 lists the IO classes and Figure 8.1 on the next page illustrates the inheritance relationships among these types. Inheritance is usually illustrated similarly to how a family tree is displayed. The topmost circle represents a base (or parent) class. Lines connect a base class to its derived (or children) class(es). So, for example, this figure indicates that istream is the base class of ifstream and istringstream. It is also the base class for iostream, which in turn is the base class for sstream and fstream classes.Because the types ifstream and istringstream inherit from istream, we already know a great deal about how to use these types. Each program we've written that read an istream could be used to read a file (usingthe ifstream type) or a string (using the istringstream type). Similarly, programs that did output could use an ofstream or ostringstream instead of ostream. In addition to the istream and ostream types, the iostream header also defines the iostream type. Although our programs have not used this type, we actually know a good bit about how to use an iostream. The iostream type is derived from both istream and ostream. Being derived from both types means that an iostream object shares the interface of both its parent types. That is, we can use an iostream type to do both input and output to the same stream. The library also defines two types that inherit from iostream. These types can be used to read or write to a file or a string.Using inheritance for the IO types has another important implication: As we'll see in Chapter 15, when we have a function that takes a reference to a base-class type, we can pass an object of a derived type to that function. This fact means that a function written to operate on istream& can be called with an ifstream or istring stream object. Similarly,a function that takes an ostream& can be called with an ofstream or ostring stream object. Because the IO types are related by inheritance, we can write one function and apply it to all three kinds of streams: console, disk files, or string streams.International Character SupportThe stream classes described thus far read and write streams composed of type char. The library defines a corresponding set of types supporting the wchar_t type. Each class is distinguished from its char counterpart by a "w" prefix. Thus, the types wostream, wistream, and wiostream read and write wchar_t data to or from a console window. The file input and output classes are wifstream, wofstream, and wfstream. The wchar_t versions of string stream input and output are wistring stream, wostring stream, and wstring stream. The library also defines objects to read and write wide characters from the standard input and standard output. These objects are distinguished from the char counterparts by a "w" prefix: The wchar_t standard input object is named wcin; standard output is wcout; and standard error is wcerr.Each of the IO headers defines both the char and wchar_t classes and standard input/output objects. The stream-based wchar_t classes and objects are defined in iostream, the wide character file stream types in fstream, and the wide character string streams in sstream.No Copy or Assign for IO ObjectsFor reasons that will be more apparent when we study classes and inheritance in Parts III and IV, the library types do not allow allow copy or assignment.This requirement has two particularly important implications. As we'll see in Chapter 9, only element types that support copy can be storedin vectors or other container types. Because we cannot copy stream objects, we cannot have a vector (or other container) that holds stream objects.The second implication is that we cannot have a parameter or return type that is one of the stream types. If we need to pass or return an IO object, it must be passed or returned as a pointer or reference.Typically, we pass a stream as a nonconst reference because we pass an IO object intending to read from it or write to it. Reading or writing an IO object changes its state, so the reference must be nonconst.8.2. Condition StatesBefore we explore the types defined in fstream and sstream, we need to understand a bit more about how the IO library manages its buffers and the state of a stream. Keep in mind that the material we cover in this section and the next applies equally to plain streams, file streams, or string streams.Inherent in doing IO is the fact that errors can occur. Some errors are recoverable; others occur deep within the system and are beyond the scope of a program to correct. The IO library manages a set of condition state members that indicate whether a given IO object is in a usable state or has encountered a particular kind of error. The library also defines a set of functions and flags, listed in Table 8.2, that give us access to and let us manipulate the state of each stream.If we enter Borges on the standard input, then cin will be put in an error state following the unsuccessful attempt to read a string of characters as an int. Similarly, cin will be in an error state if we enter an end-of-file. Had we entered 1024, then the read would be successful and cin would be in a good, non-error state.To be used for input or output, a stream must be in a non-error state. The easiest way to test whether a stream is okay is to test its truth value.The if directly tests the state of the stream. The while does so indirectly by testing the stream returned from the expression in the condition. If that input operation succeeds, then the condition tests true.Condition StatesMany programs need only know whether a stream is valid. Other programs need more fine-grained access to and control of the state of the stream. Rather than knowing that the stream is in an error state, we might want to know what kind of error was encountered. For example, we might want to distinguish between reaching end-of-file and encountering an error on the IO device.Each stream object contains a condition state member that is managed through the setstate and clear operations. This state member has type iostate, which is a machine-dependent integral type defined by eachiostream class. It is used as a collection of bits, much the way we used the int_quiz1 variable to represent test scores in the example in Section 5.3.1 (p. 156).Each IO class also defines three const values of type iostate that represent particular bit patterns. These const values are used to indicate particular kinds of IO conditions. They can be used with the bitwise operators (Section 5.3, p. 154) to test or set multiple flags in one operation.The badbit indicates a system level failure, such as an unrecoverable read or write error. It is usually not possible to continue using a stream after such an error. The failbit is set after a recoverable error, such as reading a character when numeric data was expected. It is often possible to correct the problem that caused the failbit to be set. The eofbit is set when an end-of-file is encountered. Hitting end-of-file also sets the failbit.The state of the stream is revealed by the bad, fail, eof, and good operations. If any of bad, fail, or eof are true, then testing the stream itself will indicate that the stream is in an error state. Similarly, the good operation returns TRue if none of the other conditions is true.The clear and setstate operations change the state of the condition member. The clear operations put the condition back in its valid state. They are called after we have remedied whatever problem occurred and we want to reset the stream to its valid state. The setstate operation turns on the specified condition to indicate that a problem occurred. setstate leaves the existing state variables unchanged except that it adds the additional indicated state(s).Accessing the Condition StateThe rdstate member function returns an iostate value that corresponds to the entire current condition state of the stream.Dealing with Multiple StatesOften we need to set or clear multiple state bits. We could do so by making multiple calls to the setstate or clear functions. Alternatively, we could use the bitwise OR (Section 5.3, p. 154) operator to generate a value to pass two or more state bits in a single call. The bitwise OR generates an integral value using the bit patterns of its operands. For each bit in the result, the bit is 1 if the corresponding bit is 1 in either of its operands.第八章标准IO 库C++ 的输入/输出(input/output)由标准库提供。
Visual C++程序设计21世纪将是信息化社会,以信息技术为主要标志的高新技术产业在整个经济中的比重不断增长,随着计算机技术的飞速发展,社会对人才的计算机应用与开发水平的要求也日益增高,为适应形式,其中VC++技术及其产品是当今世界计算机发展的一块巨大领域。
Windows xp/vista 是目前主流图形化操作系统,运行各种各样的window操作系统的个人计算机已在全球的家庭和办公坏境中广泛使用,而越来越多的个人计算机具有internet功能和多媒体功能又推动了对各种各样功能强,速度快的应用软件的进一步需求。
目前有一种对microsoft所取得的成功进行诽谤的气氛,然而,microsoft的成功加上它对标准化的承诺,使得有承诺的windows编程人员利用他们掌握的技术在全球范围内得到越来越大的回报,由于西方社会的承认和计算机已越来越深入到每个人的生活中,因而对他们的技术需求与日俱增,从而使得他们的回报、经济收入和其他各方面相应地取得了满意的结果。
Visual C++编程语言是由Microsoft公司推出的目前极为广泛的可视化开发工具,利用Visual C++可以开发基于Widnows平台的32位应用程序,依靠强大的编译器以及网络与数据库的开发能力,用Visual C++可以开发出功能强大的应用程序。
VC++6.0是操作系统中快速应用开发环境的最新版本。
它也是当前Windows平台上第一个全面支持最新WEB服务的快速开发工具。
无论是企业级用户,还是个人开发者,都能够利用VC++6.0轻松、快捷地开发优秀的基于通信的程序,开发高效灵活的文件操作程序,开发灵活高效的数据库操作程序,等等。
VC++6.0是惟一支持所有新出现的工业标准的RAD坏境,包括XML(扩展标记语言)/XSL(可扩展样式语言),SOAP(简单对象存取协议)和WSDL(Web 服务器描述语言)等。
VC++6.0是可视化的快速应用程序开发语言,它提供了可视化的集成开发坏境,这一坏境为应用程序设计人员提供了一系列灵活先进的工具,可以广泛地用于种类应用程序设计。
C++多平台中英文资料外文翻译文献外文原文From one code base to many platforms using Visual C++Multiple-platform development is a hot issue today. Developers want to be able to support diverse platforms such as the Microsoft® Windows® version 3.x, Microsoft Windows NT®, and Microsoft Windows 95 operating systems, and Apple®, Macintosh®, UNIX, and RISC (reduced instruction set computer) machines. Until recently, developers wanting to build versions of their application for more than one platform had few choices: ∙Maintain separate code bases for each platform, written to the platform's native application programming interface (API).∙Write to a "virtual API" such as those provided by cross-platform toolsets.∙Build their own multiple-platform layer and support it.Today, however, a new choice exists. Developers can use their existing code written to the Windows API and, using tools available from Microsoft and third parties, recompile for all of the platforms listed above. This paper looks at the methods and some of the issues involved in doing so.Currently the most lucrative market for graphical user interface (GUI) applications, after Microsoft Windows, is the Apple Macintosh. However, vast differences separate these wholly different operating systems, requiring developers to learn new APIs, programming paradigms, and tools. Generally, Macintosh development requires a separate code base from the Windows sources, increasing the complexity of maintenance and enhancement.Because porting code from Windows to the Macintosh can be the most difficult porting case, this paper concentrates in this area. In general, if your code base is sufficiently portable to enable straightforward recompiling for the Macintosh (excluding any platform-specific, or "edge" code, you may elect to include), you'll find that it will come up on other platforms easily as well.Microsoft Visual C++® Cross-Development Edition for Macintosh (Visual C++ for Mac™) provides a set of Windows NT– or Windows 95–hosted tools for recompiling your Windows code for the Motorola 680x0 and PowerPC processors, and a portability library that implements Windows on the Macintosh. This allows you to develop GUI applications with a single source code base (written to the Win32® API) and implement it on Microsoft Windows or Apple Macintosh platforms.Figure 1, below, illustrates how Visual C++ for Mac works. Your source code is edited, compiled, and linked on a Windows NT–or Windows 95–based (Intel) host machine. The tools create 68000 and PowerPC native code and Macintosh resources. An Ethernet-based or serial transport layer (TL) moves the resulting binaries to a Macintosh target machine running remotely. The Macintosh application is started on the Macintosh and debugged remotely from the Windows-based machine.Now that Apple has two different Macintosh architectures to contend with (Motorola 680x0 and PowerPC) portability is particularly important.Porting can involve several steps, depending on whether you are working with old 16-bit applications or with new 32-bit sources. In general, the steps to a Macintosh port are as follows:1.Make your application more portable by following some general portability guidelines.This will help insure not only portability to the 680x0-based Macintosh machines, but also to the newer, more powerful PowerPC machines that are based on a RISC chip.2.Port your application from Windows 16-bit code to 32-bit code. This may be the mostcomplex and time-consuming part of the job.3.Segregate those parts of your application that are unique to Windows from similarimplementations that are specific to the Macintosh. This may involve using conditional compilation or it may involve changing the source tree for your project.4.Port your Win32 API code to the Macintosh by using the portability library for theMacintosh and Visual C++ for compiling, linking, and debugging.e the Microsoft Foundation Class Library (MFC) version 4.0 to implement newfunctionality such as OLE 2.0 containers, servers, and clients or database supportusing open database connectivity (ODBC). Code written using MFC is highly portable to the Macintosh.6.Write Macintosh-specific code to take advantage of unique Macintosh features, suchas Apple Events or Publish and Subscribe.The chief challenge among the families of Windows operating systems is the break from 16 bits (Windows 3.11 and Windows for Workgroups 3.11 operating system with integrated networking) to 32 bits (Windows NT and Windows 95). In general, 16-bit and 32-bit code bases are somewhat incompatible, unless they are written using MFC. Developers have the choice of branching their sources into two trees, or migrating everything to 32 bits. Once the Win32 choice has been made, how are legacy platforms to be run (that is, machines still running Windows 3.11)? The obvious choice is to use the Win32s® API libraries, which thunk 32-bit calls down to their 16-bit counterparts.Developers who want their applications to be able to take advantage of the hot new RISC hardware, such as DEC Alpha AXP machines, can use the special multiple platform editions of Visual C++. These include versions for the MIPS R4000 series of processors as well as the aforementioned DEC Alpha AXP chip and the Motorola Power PC. These toolsets run under Windows NT 3.51 and create highly optimized native Win32 applications for DEC Alpha and Motorola PowerPC platforms.Developers who have recompiled their Win32 sources using these toolsets are amazed at how simple it is. Since the operating system is identical on all platforms, and the tools are identical, little work has to be done in order to achieve a port. The key difference in the RISC machines from Intel is the existence of a native 64-bit integer, which is far more efficient than on 32-bit (that is, Intel) processors.Microsoft works closely with two third-party UNIX tools providers, Bristol Technology and Mainsoft Corporation, to allow developers to recompile their Win32-based or MFC-based applications for UNIX. Developers seeking additional information should contact those companies directly.You'll have to decide early on whether to write to the native API (Win32) or to MFC. In general you'll find MFC applications will port more quickly than Win32 applications. This is because one of the intrinsic benefits of an application framework is an abstraction of the code away from the native operating system to some extent. This abstraction is like an insurance policy for you. However, developers frequently have questions about MFC, such as: What if I need an operating system service that isn't part of the framework?Call the Win32 API directly. MFC never prevents you from calling any function in the Win32 API directly. Just precede your function call with the global scope operator (::).∙I don't know C++. Can I still use MFC?Sure. MFC is based on C++, but you can mix C and C++ code seamlessly.∙How can I get started using MFC?Start by taking some classes and/or reading some books. Visual C++ ships with a fine tutorial on MFC (Scribble). Then, check out the MFC Migration Kit (available on CompuServe or, for a modest shipping and handling fee, from Microsoft). It will help you migrate your C-based application code to MFC and C++.All porting will be easier if you begin today writing more portable programs. Following some basic portability guidelines will make your code less platform-specific.Never assume anything. Particularly, don't make assumptions about the sizes of types, the state of the machine at any time, byte ordering, or alignment.Don't assume the size of primitive types, because these have different sizes on different processors. For example, an int is two bytes in Win16 and four bytes in Win32. At all costs, avoid code that relies on the size of a type. Use sizeof() instead. To determine the offset of a field in a structure, use the offsetof() macro. Don't try to compute this manually.Use programmatic interfaces to access all system or hidden "objects," for example, the stack or heap.Parsing data types to extract individual bytes or even bits can cause problems when porting from Windows to the Macintosh unless you are careful to write code that doesn't assume any particular byte order. LIMITS.H contains constants that can be used to help write platform-independent macros to access individual bytes in a word.This may seem obvious, because nothing could be less portable than assembly language. Compilers, such as Microsoft Visual C++, that provide inline assemblers make it easy to slip in a little assembler code to speed things up. If you want portable code, however, avoid this temptation. It may not be necessary. Modern compilers can often generate code as good as hand-tuned native assembler code. Our own research at Microsoft indicates that performance problems are more often the result of poor algorithms than they are of poor code generation. Indeed, with RISC machines, hand-turned native assembler code may actually be worse than machine-generated code, due to the complexity of instruction scheduling and picking register usage.Write all routines in C first; then, if you absolutely need to rewrite one in assembler, be sure to leave both implementations in your sources, controlled by conditional compiles, and keep both up to date.A major goal of American National Standards Institute (ANSI) C/C++ is to provide a portable implementation of the language. Theoretically, code written to strict ANSI Ccompliance is completely portable to any compiler that implements the standard correctly. Microsoft Visual C++ provides a compiler option (/Za) to enable strict ANSI compatibility checking.Microsoft Visual C++ provides some language features that are in addition to ANSI C, such as four-character constants and single-line comments. Programs that use the Microsoft C extensions should be portable to all other implementations of Microsoft Visual C++. Thus, you can write programs that use four-character constants, for example, and know that your program is portable to any 16-bit or 32-bit Microsoft Windows platform or to the Macintosh.Compilers normally align structures based on the target machine architecture; some RISC machines, such as the MIPS R4000, are particularly sensitive to alignment. Alignment faults may generate run-time errors or, instead, may silently and seriously degrade the performance of your application. For portability, therefore, avoid packing structures. Limit packing to hardware interfaces and to compatibility issues such as file formats and on-disk structures.Using function prototypes is mandatory for fully portable code. All functions should be prototyped, and the prototype should exactly match the actual function declaration.Following the guidelines above will make your code a lot more portable. However, if you have 16-bit Windows code, your first step is to make it work properly under Win32. This will require additional changes in your sources.Code written for Win32 can run on any version of Windows, including on the Macintosh, using the portability library. Portable code should compile and execute properly on any platform. Of course, if you use APIs that only function under Windows NT, they will not work when your application runs under Windows 3.x. For example, threads work under Windows NT but not under Windows 3.11. Those types of functionality differences will have to be accounted for in the design of your application.Chief among the differences between Win16 and Win32 is linear addressing. That means pointers are now 32 bits wide and the keywords near and far are no longer supported. It also means code that assumes segmented memory will break under Win32.In addition to pointers, handles and graphic coordinates are now 32 bits. WINDOWS.H will resolve many of these size differences for you, but some work is still necessary.The recommended strategy to get your application running under Win32 is to recompile for 32 bits, noting error messages and warnings. Next, replace complex procedures and assembly language routines with stub procedures. Then, make your main program work properly using the techniques above. Finally, replace each stubbed-out procedure with a portable version.After you successfully convert your Windows-based program from 16 bits to 32 bits, you're ready to embark on porting it to the Macintosh. Because significant differences exist between the two platforms, this task can appear daunting. Before you can begin to port your application, you need to better understand these differences. The Macintosh is differentiated from Windows in three general areas:∙Programming model differences∙Processor differences∙User interface (UI) differencesThese areas of difference are described below. Porting issues that accompany these differences are discussed in the section titled "Porting from Win32 to the Macintosh."The Windows and Macintosh APIs are completely different. For example:∙The event models are different. In Windows, you dispatch messages to WindowProcs.You use DefWindowProc to handle messages in which you're not specifically interested. On the Macintosh, you have a big main event loop to handle all possible events.∙Windows uses the concept of child windows. The Macintosh uses no child windows.∙Windows-based applications can draw using either pens or brushes. Macintosh applications can use only pens.∙Controls in Windows are built-in window classes. On the Macintosh, controls are unrelated to windows.∙Windows allows for 256 binary raster operations; the Macintosh allows for only 16.Because of the differences between the two platforms, porting a Windows-based application to the Macintosh can be monumental task without powerful tools.Windows has always run on Intel x86 processors (until Windows NT), and the Macintosh has run on Motorola 680x0 processors (of course, the PowerPC-based Macintosh is now available as well). Differences between the processor families include addressing and byte ordering, in addition to the more expected differences like opcodes, instruction sets, and the name and number of registers.The Intel 8086 processor, from which subsequent 80x86 processors are descended, used 16-bit addresses, which unfortunately allowed only 65,536 bytes of memory to be addressed. To allow the use of more memory, Intel implemented a segmented memory architecture to address one megabyte (2^20 bytes) of memory that used an unsigned 16-bit segment register and an unsigned 16-bit offset. This original Intel scheme has been extended to allow much larger amounts of memory to be addressed, but most existing Intel-based programming relies on separating code and data into 64K segments.Although all Intel x86 processors since the 80386 have used 32-bit addressing, for compatibility reasons Microsoft Windows 3.x is actually a 16-bit application, and all Microsoft Windows-based applications had to be written as 16-bit applications. That meant, for example, that most pointers and handles were 16 bits wide. With the advent of Microsoft Windows NT, which is a true 32-bit operating system, all native applications are 32-bit applications, which means that pointers and handles are 32 bits wide. Because Windows NT uses linear addressing, programs can share up to 4 gigabytes of memory.In contrast, the Motorola 68000 and PowerPC processor have always provided the ability to address a "flat" 32-bit memory space. In theory, a flat memory space of this kind simplifies memory addressing. In practice, because 4-byte addresses are too large to use all the time, Macintosh code is generally divided into segments no larger than 32K.Microsoft Windows and Windows NT run only on so-called "little-endian" machines—processors that place the least significant byte first and the most significant byte last. In contrast, the Motorola 680x0 and PowerPC (a so-called "big-endian" architecture) place the most significant byte first, followed by the next most significant byte, and so on, with the least significant byte last.Compilers normally handle all details of byte ordering for your application program. Nevertheless, well-written portable code should never depend on the order of bytes.Microsoft Windows and the Macintosh present quite different user interfaces in many key areas, including menus, filenames, and multiple-document interface (MDI) applications.Only one menu bar exists on the Macintosh, and it is always in the same place, regardless of the number or arrangement of windows on the screen. The "active window" contains the menu, which dynamically changes as necessary when different windows are made active. Windows, on the other hand, gives each top-level window its own menu. In addition, under MDI, each child window can also have its own menu. MDI is discussed in greater detail below.Macintosh applications generally have an "Apple menu" (the leftmost menu) that contains all the installed Desk Accessories and usually contains an About entry for the application. Under System 7, the extreme right side of the Macintosh menu contains an icon for Apple's Balloon Help and the Application menu for switching between applications.Windows-based applications always have a System menu at the upper-left corner of their top-level window. This menu contains system-level functions for sizing, moving, and closing the window, as well as an item that calls the Task Manager for switching applications.Generally, Windows-based applications contain keyboard equivalents in their menus. These are underlined letters in each menu entry that the user can select with the keyboard inlieu of the mouse. This, however, is convention rather than requirement. Although some Macintosh applications have these equivalents, most do not.Filenames and pathnames represent one of the most fundamental differences between Windows and the Macintosh, as well as perhaps the one most difficult to deal with. Many programmers report dealing with filenames as the area of porting in which the most time and energy is spent.Your Windows-based application probably already handles (and expects) filenames such as "C:\ACCTG\DATA\SEPT93.DAT." Applications for the MS-DOS and Windows operating systems are bound by the traditional 8.3 filename format. Macintosh applications, on the other hand, can handle filenames such as "September, 1993 Accounting Data."MDI windows allow for multiple child windows within the borders of a top-level window (the "MDI frame"). Many Windows-based applications, such as the Microsoft Word word processor for Windows, are MDI applications. Characteristic of MDI applications are clipped child windows that can be minimized to an icon within the MDI frame. Each MDI child window can also have its own menu.The Macintosh does not support MDI windows. An application can have multiple windows open; those windows, however, cannot be made into icons, and they share a common menu. Depending on the application, this difference may necessitate significant redesign for a Macintosh port.Finally you can keep doing what you know how to do best, writing to the Windows API, and still allow for versions of your application that run on other platforms. Visual C++ now gives you special versions that allow you to do this. Keeping your code portable, thinking about portability all the time, and using the right tools will help you make the multiple platform jump as effortless as possible..中文翻译在今天,多平台的开发是一个热门课题。
毕业设计(论文)外文文献翻译文献、资料中文题目:Visual C++ MFC 简要介绍文献、资料英文题目:文献、资料来源:文献、资料发表(出版)日期:院(部):专业:班级:姓名:学号:指导教师:翻译日期: 2017.02.14Introduction to MFC Programming with Visual C++ Version 6.xby Marshall Brain Visual C++ is much more than a compiler. It is a complete 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 compatible 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, compile, 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?Let'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 time-honored 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 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 Window's API Reference books. For Window's NT, the API is typically referred to as the "Win32 API," to distinguish it from the original 16-bit API of lower-level Windows products like Windows 3.1.Microsoft also provides a C++ library that sits on top of any of the Windows APIs and makes the programmer's job easier. Called the Microsoft Foundation Class library (MFC), this library'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 3.1 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 example, if the user clicks a button, you want to have code in place that responds appropriately. It is this sort of event-handling code that will form the bulk of any application. Once the application responds correctly to all of the available controls, it is finished.You can see from this discussion that the creation of a Windows program is a straightforward process when using MFC. The goal of these tutorials is to fill in the details and to show the techniques you can use to create professional applications as quickly as possible. The Visual C++ application development environment is specifically tuned to MFC, so by learning MFC and Visual C++ together you can significantly increase your power as an application developer.Windows VocabularyThe vocabulary used to talk about user interface features and software development in Windows is basic but unique. Here we review a few definitions to make discussion easier for those who are new to the environment.Windows applications use several standard user controls:Static text labelsPush buttonsList boxesCombo boxes (a more advanced form of list)Radio boxesCheck boxesEditable text areas (single and multi-line)Scroll barsYou can create these controls either in code or through a "resource editor" that can create dialogs and the controls inside of them. In this set of tutorials we will examine how to create them in code. See the tutorials on the AppWizard and ClassWizard for an introduction to the resource editor for dialogs.Windows supports several types of application windows. A typical application will live inside a "frame window". A frame window is a fully featured main window that the user can re-size, minimize, maximize to fill the screen, and so on. Windows also supports two types of dialog boxes: modal and modeless. A modal dialog box, once on the screen, blocks input to the rest of the application until it is answered. A modeless dialog box can appear at the same time as the application and seems to "float above" it to keep from being overlaid.Most simple Windows applications use a Single Document Interface, or SDI, frame. TheClock, PIF editor, and Notepad are examples of SDI applications. Windows also provides an organizing scheme called the Multiple Document Interface, or MDI for more complicated applications. The MDI system allows the user to view multiple documents at the same time within a single instance of an application. For example, a text editor might allow the user to open multiple files simultaneously. When implemented with MDI, the application presents a large application window that can hold multiple sub-windows, each containing a document. The single main menu is held by the main application window and it applies to the top-most window held within the MDI frame. Individual windows can be iconified or expanded as desired within the MDI frame, or the entire MDI frame can be minimized into a single icon on the desktop. The MDI interface gives the impression of a second desktop out on the desktop, and it goes a long way towards organizing and removing window clutter.Each application that you create will use its own unique set of controls, its own menu structure, and its own dialog boxes. A great deal of the effort that goes into creating any good application interface lies in the choice and organization of these interface objects. Visual C++, along with its resource editors, makes the creation and customization of these interface objects extremely easy.Event-driven Software and V ocabularyAll window-based GUIs contain the same basic elements and all operate in the same way. On screen the user sees a group of windows, each of which contains controls, icons, objects and such that are manipulated with the mouse or the keyboard. The interface objects seen by the user are the same from system to system: push buttons, scroll bars, icons, dialog boxes, pull down menus, etc. These interface objects all work the same way, although some have minor differences in their "look and feel." For example, scroll bars look slightly different as you move from Windows to the Mac to Motif, but they all do the same thing.From a programmer'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 un-editable text area, and let the user exit the program by clicking on a push-button labeled "quit".As the user manipulates the application's controls, the program must respond appropriately. The responses are determined by the user's actions on the different controls using the mouse and the keyboard. Each user interface object on the screen will respond to events differently. For example, if the user clicks the Quit button, the button must update the screen appropriately, highlighting itself as necessary. Then the program must respond by quitting. Normally the button manages its appearance itself, and the program in some way receives a message from the buttonthat says, "The quit button was pressed. Do something about it." The program responds by exiting.Windows follows this same general pattern. In a typical application you will create a main window and place inside it different user interface controls. These controls are often referred to as child windows-each control is like a smaller and more specialized sub-window inside the main application window. As the application programmer, you manipulate the controls by sending messages via function calls, and they respond to user actions by sending messages back to your code.If you have never done any "event-driven" programming, then all of this may seem foreign to you. However, the event-driven style of programming is easy to understand. The exact details depend on the system and the level at which you are interfacing with it, but the basic concepts are similar. In an event-driven interface, the application paints several (or many) user interface objects such as buttons, text areas, and menus onto the screen. Now the application waits-typically in a piece of code called an event loop-for the user to do something. The user can do anything to any of the objects on screen using either the mouse or the keyboard. The user might click one of the buttons, for example. The mouse click is called an event. Event driven systems define events for user actions such as mouse clicks and keystrokes, as well as for system activities such as screen updating.At the lowest level of abstraction, you have to respond to each event in a fair amount of detail. This is the case when you are writing normal C code directly to the API. In such a scenario, you receive the mouse-click event in some sort of structure. Code in your event loop looks at different fields in the structure, determines which user interface object was affected, perhaps highlights the object in some way to give the user visual feedback, and then performs the appropriate action for that object and event. When there are many objects on the screen the application becomes very 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 low-level 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 pre-arranged 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 mapsAn ExampleOne of the best ways to begin understanding the structure and style of a typical MFC program is to enter, compile, and run a small example. The listing below contains a simple "hello world" program. If this is the first time you've seen this sort of program, it probably will not make a lot of sense initially. Don't worry about that. We will examine the code in detail in the nexttutorial. For now, the goal is to use the Visual C++ environment to create, compile and execute this simple program.//hello.cpp#include <afxwin.h>// Declare the application classclass CHelloApp : public CWinApp{public:virtual BOOL InitInstance();};// Create an instance of the application classCHelloApp HelloApp;// Declare the main window classclass CHelloWindow : public CFrameWnd{CStatic* cs;public:CHelloWindow();};// The InitInstance function is called each// time the application first executes.BOOL CHelloApp::InitInstance(){m_pMainWnd = new CHelloWindow();m_pMainWnd->ShowWindow(m_nCmdShow);m_pMainWnd->UpdateWindow();return TRUE;}// The constructor for the window classCHelloWindow::CHelloWindow(){// Create the window itselfCreate(NULL,"Hello World!",WS_OVERLAPPEDWINDOW,CRect(0,0,200,200));// Create a static labelcs = new CStatic();cs->Create("hello world",WS_CHILD|WS_VISIBLE|SS_CENTER,CRect(50,80,150,150),this);}This small program does three things. First, it creates an "application object." Every MFC program you write will have a single application object that handles the initialization details of MFC and Windows. Next, the application creates a single window on the screen to act as the main application window. Finally, inside that window the application creates a single static text label containing the words "hello world". We will look at this program in detail in the next tutorial to gain a complete understanding of its structure.The steps necessary to enter and compile this program are straightforward. If you have not yet installed Visual C++ on your machine, do so now. You will have the option of creating standard and custom installations. For the purposes of these tutorials a standard installation is suitable and after answering two or three simple questions the rest of the installation is quick and painless.Start VC++ by double clicking on its icon in the Visual C++ group of the Program Manager. If you have just installed the product, you will see an empty window with a menu bar. If VC++ has been used before on this machine, it is possible for it to come up in several different states because VC++ remembers and automatically reopens the project and files in use the last time it exited. What we want right now is a state where it has no project or code loaded. If the program starts with a dialog that says it was unable to find a certain file, clear the dialog by clicking the "No" button. Go to the Window menu and select the Close All option if it is available. Go to the File menu and select the Close option if it is available to close any remaining windows. Now you are at the proper starting point. If you have just installed the package, you will see a window that looks something like this:This screen can be rather intimidating the first time you see it. To eliminate some of the intimidation, click on the lower of the two "x" buttons () that you see in the upper right hand corner of the screen if it is available. This action will let you close the "InfoViewer Topic" window. If you want to get rid of the InfoViewer toolbar as well, you can drag it so it docks somewhere along the side of the window, or close it and later get it back by choosing the Customize option in the Tools menu.What you see now is "normal". Along the top is the menu bar and several toolbars. Along the left side are all of the topics available from the on-line book collection (you might want to explore by double clicking on several of the items you see there - the collection of information found in the on-line books is gigantic). Along the bottom is a status window where various messages will be displayed.Now what? What you would like to do is type in the above program, compile it and run it. Before you start, switch to the File Manager (or the MS-DOS prompt) and make sure your drive has at least five megabytes of free space available. Then take the following steps.Creating a Project and Compiling the CodeIn order to compile any code in Visual C++, you have to create a project. With a very small program like this the project seems like overkill, but in any real program the project concept is quite useful. A project holds three different types of information:It remembers all of the source code files that combine together to create one executable. In this simple example, the file HELLO.CPP will be the only source file, but in larger applications you often break the code up into several different files to make it easier to understand (and also to make it possible for several people to work on it simultaneously). The project maintains a list of the different source files and compiles all of them as necessary each time you want to create a new executable.It remembers compiler and linker options particular to this specific application. For example,it remembers which libraries to link into the executable, whether or not you want to use pre-compiled headers, and so on.It remembers what type of project you wish to build: a console application, a windows application, etc.If you are familiar with makefiles, then it is easy to think of a project as a machine-generated makefile that has a very easy-to-understand user interface to manipulate it. For now we will create a very simple project file and use it to compile HELLO.CPP.To create a new project for HELLO.CPP, choose the New option in the File menu. Under the Projects tab, highlight Win32 Application. In the Location field type an appropriate path name or click the Browse button. Type the word "hello" in for the project name, and you will see that word echoed in the Location field as well. Click the OK button. In the next window, use the default selection "An empty project", click "Finish", then click "OK" once more in the next window. Notice there is an option for the typical "Hello World" application, however it skips a few important steps you are about to take. Visual C++ will create a new subdirectory named HELLO and place the project files named HELLO.OPT, HELLO.NCB, HELLO.DSP, and HELLO.DSW in that directory. If you quit and later want to reopen the project, double-click on HELLO.DSW.The area along the left side of the screen will now change so that three tabs are available. The InfoView tab is still there, but there is now also a ClassView and a FileView tab. The ClassView tab will show you a list of all of the classes in your application and the FileView tab gives you a list of all of the files in the project.Now it is time to type in the code for the program. In the File menu select the New option to create a new editor window. In the dialog that appears, make sure the Files tab is active and request a "C++ Source File". Make sure the "Add to Project" option is checked for Project "hello", and enter "hello" for "File name". Visual C++ comes with its own intelligent C++ editor, and you will use it to enter the program shown above. Type (copy/paste) the code in the listing into the editor window. You will find that the editor automatically colors different pieces of text such as comments, key words, string literals, and so on. If you want to change the colors or turn the coloring off, go to the Options option in the Tools menu, choose the Format tab and select the Source Windows option from the left hand list. If there is some aspect of the editor that displeases you, you may be able to change it using the Editor tab of the Options dialog.After you have finished entering the code, save the file by selecting the Save option in the File menu. Save it to a file named HELLO.CPP in the new directory Visual C++ created.In the area on the left side of the screen, click the FileView tab and expand the tree on the icon labeled "hello files", then expand the tree on the folder icon labeled "Source Files". You will see the file named HELLO.CPP. Click on the ClassView tab and expand the "hello classes" tree and you will see the classes in the application. You can remove a file from a project at any time by going to the FileView, clicking the file, and pressing the delete button.Finally, you must now tell the project to use the MFC library. If you omit this step the project。