One.VC + + and MFC
Talk about VC is unavoidable to mention MFC,MFC full name Microsoft Foundation Classes, that is, Microsoft Foundation Class Library . It is the core of VC + +, is a combination of C + + and Windows API, very thorough in C + + encapsulated the Windows SDK (software Development Kit, software Development Kit) in the structure and functionality, also provides an application framework, This application framework has done some routine work for software developers, such as Windows, toolbars, menu generation and management, without the need for developers to solve complex and tedious problems, such as using Windows API to register, generate, and manage each window. This greatly reduces the workload of the software developer and improves the development efficiency.
Of course, VC + + is not only able to create MFC applications, the same can be the Windows SDK programming, but then abandon the core of VC + +, give up the most powerful part of VC + +. MFC is not only used in VC + +, it can also be used in Borland C + + and other compilers, of course, few people do so.
Turn from: VS2010/MFC before you start programming
Two. Using the VS2010 Application Wizard to generate a single document application framework
1. Click the menu bar File->new->project, pop Up the New Project dialog box, we can select the project type.
If the first startup is set to VC + + after VS2010 is installed, the installed templates->visual C + + key will be expanded by default, and if VC + + is not set, you can expand to installed Templates-> Other languages->visual C + + items.
Because we are going to build an MFC program, under "Visual C + +" Select "MFC", there will be three options in the middle of the dialog box: MFC ActiveX Control, MFC application, and MFC DLLs. MFC ActiveX control is used to build an MFC ActiveX Controls program. MFC application is used to build MFC applications. MFC DLLs are used to generate MFC dynamic link library programs. Of course we have to choose MFC Application.
In the lower part of the dialog there is the name, location, and solution name three settings. The meaning is as follows: name--project name, location--solution Path, Solution name--solution name. Here name we set as "HelloWorld", location set to "desktop" path, solution name default and name, of course, can be modified to other names, here we do not modify, also use "HelloWorld".
Click the "OK" button.
2. The MFC Application Wizard dialog box pops up with the "Welcome to the MFC Application Wizard" at the top, and the default settings for the current project are shown below. The first "tabbed Multiple Document Interface (MDI)" means that this project is a multi-document application. If you just click the "Finish" button below, you can generate a multi-document program with the settings listed above. But our example is to create a single document application, so click the "Next" button to continue setting it.
3. The next pop-up dialog has "application Type" in the upper part, and of course it lets you choose the application type, we see Four types:single document, multiple documents (multiple file), Dialog Based (Based on dialog box) and multiple top-level documents. We select the single document type to generate a monolithic application framework. A single-document application runs as a single-window interface.
The Resource language of this dialog box also provides a choice of languages.
Project style allows you to choose the engineering styles, and we choose the default Visual Studio style.
The "Use of MFC" has two options: Use the MFC in a shared DLL (dynamic-link library mode using MFC) and using MFC in a static library (static libraries mode uses MFC). The MFC class is accessed as a dynamic-link library When you select the use of the MFC in a shared DLL, so our application itself is smaller, but the application must be published with the necessary dynamic-link libraries in order to run the program properly without the VS2010 installed . When you select the use of MFC in a static library, the MFC classes are compiled into the executable, so the application's executables are larger than the previous one, but can be published separately without the need for a library containing MFC classes. Here we use the default using MFC in a shared DLL.
Click the "Next" button.
4. This pops up a dialog box with "Compound document support" In it, which you can use to add OLE support to your application, specifying the compound document type for OLE options . This example does not require an OLE attribute, using the default value of "None". Click the "Next" button.
5. A new dialog box appears with "Document Template Properties" in the upper part. "File extension" can set the extension of files that the program can handle. dialog box Other options can also change the title of the program window. We all use the default settings and click the "Next" button.
6. The topic of the dialog box that pops up is "Database support". Used to set database options. This wizard generates the code required by your database application . It has four options:
None: Ignore all database support;
Header files only: contains only the header file that defines the database class, but does not generate a database class or view class corresponding to a particular table;
Database view without file support: Creates a DB Class and a view class corresponding to the specified table, without supporting standard files;
Database view with file support: Creates a DB Class and a view class corresponding to the specified table, with additional standard file supports.
This example chooses the default value of "None" and does not use database attributes. Click the "Next" button.
7. The dialog box that pops up is about "user Interface Features", which is the UI feature. We can set either the Maximize button, the Minimize button, the System menu, the initial status bar, and so on. You can also choose to use the menu bar and toolbars to generate a simple application or to use the ribbon. Here we all choose the default settings. Click "Next" to proceed to the next step.
8. The Advanced Features dialog box is displayed. Advanced features that you can set include print and print preview , and so on. The "Number of files on recent file list" entry can be set in the program interface's File menu under the most recently opened file. We still use the default values. Click the "Next" button.
9. The Generate Class dialog box appears. In the Generate Class list box at the top of the dialog box, list the 4 classes that will be generated: A view class (Chelloworldview), an application Class (Chelloworldapp), A document class (Chelloworlddoc) and a main frame window class (CMainFrame). In several edit boxes below the dialog box, you can modify the default class name, the header file name of the class, and the source file name. For a view class, you can also modify its base class name, the default base class is CView, and several other base classes can be selected. Here we still use the default settings. Click the "Finish" button.
The application wizard finally generated the application framework for us and automatically opened the solution in the Solution Explorer.
Third, compile and run the generated program
Click the build->build HelloWorld Compiler in the Point menu, and then click Debug->start Without Debugging (shortcut key Ctrl+f5) to run the program, You can also directly point Debug->start without debugging, this will pop up a dialog box prompts whether to compile, select "Yes", VS2010 will automatically compile the link to run the HelloWorld program.
Well...... Error occurred while generating HelloWorld: 1>link:fatal error LNK1123: Failed during transition to COFF: invalid or corrupt file
Workaround:
Scenario 1:
Click "Project"-"Properties"-"Inventory Tool"
Then select ' Input and Output '--' embed list ' and change the ' yes ' back to ' no '.
Scenario 2: Search Cvtres.exe in VS installation directory
Found there are two cvtres.exe files, some users choose to use the latest files to cover all the old Cvtres.exe,
Also has the Netizen is deletes the old Cvtres.exe the file. I changed the name of the old Cvtres.exe to restore the environment.
Note that these two files are a version number, but the generation time is only 1 hours apart, select the latest one.
There are a lot of cvtres.exe, this is not clear, try how to delete these files.
My two files directory is as follows:
D:\Program Files (x86) \microsoft Visual Studio 10.0\vc\bin\amd64
D:\Program Files (x86) \microsoft Visual Studio 10.0\vc\bin Reference: https://zhidao.baidu.com/question/1493935034926540979. Html
I tried it this way. Program 2 succeeded.
Then run, and the results page looks like this:
Transferred from: http://www.jizhuomi.com/software/141.html
VS2010-MFC (using the MFC Wizard to generate a single document application framework)