visualcmfc简要介绍毕业设计外文翻译(编辑修改稿)内容摘要:

simply to figure out which object was clicked and what to do about it. Fortunately, you can work at a much higher level of abstraction. In MFC, almost all these lowlevel implementation details are handled for you. If you want to place a user interface object on the screen, you create it with two lines of code. If the user clicks on a button, the button does everything needed to update its appearance on the screen and then calls a prearranged function in your program. This function contains the code that implements the appropriate action for the button. MFC handles all the details for you: You create the button and tell it about a specific handler function, and it calls your function when the user presses it. Tutorial 4 shows you how to handle events using message maps An Example One of the best ways to begin understanding the structure and style of a typical MFC program is to enter, pile, and run a small example. The listing below contains a simple hello world program. If this is the first time you39。 ve seen this sort of program, it probably 沈阳航空工业学院北方科技学院毕业设计 (外文翻译 ) 6 will not make a lot of sense initially. Don39。 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, pile and execute this simple program. // include // Declare the application class class CHelloApp : public CWinApp { public: virtual BOOL InitInstance()。 }。 // Create an instance of the application class CHelloApp HelloApp。 // Declare the main window class class 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_pMainWndShowWindow(m_nCmdShow)。 m_pMainWndUpdateWindow()。 return TRUE。 } // The constructor for the window class CHelloWindow::CHelloWindow() { 沈阳航空工业学院北方科技学院毕业设计 (外文翻译 ) 7 // Create the window itself Create(NULL, Hello World!, WS_OVERLAPPEDWINDOW, CRect(0,0,200,200))。 // Create a static label cs = new CStatic()。 csCreate(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 plete understanding of its structure. The steps necessary to enter and pile 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 e 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. 沈阳航空工业学院北方科技学院毕业设计 (外文翻译 ) 8 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 online 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 online 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, pile it and run it. Before you start, switch to the File Manager (or the MSDOS 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 Code In order to pile 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 沈阳航空工业学院北方科技学院毕业设计 (外文翻译 ) 9 concept is quite useful. A project holds three different types of information: It remembers all of the source code files that bine together to create one executable. In this simple example, the file will be the only source file, but in larger applications you often break the code up。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。