It is very practical to modify the default build files and the contents of the default build project! Because of this we do not need to create a new project every time to do some of the previous work, such as the use of OpenCV to include its header files and so on, of course, in the. h file by default directly add the author, the company's description will also appear more convenient, the method is as follows:
The first is to modify the default build content of the. h and. cpp files (that is, when you add a new item, the file will bring the content you added instead of a blank piece), the problem is to find its template file path, my path is "hfile.h" " newc++file.cpp " These two files are blank by default, the former corresponds to the. h file of our new item, and the latter is the. cpp file for the new item, which means that we modify the contents of the two files to modify the default generated content accordingly. If you follow the default path to install VS, you may be unable to modify the file, I took the method is to modify the contents of the file outside the desired appearance, and then named "hfile.h" or " newc++file.cpp "re-copy in. of course, It is also perfectly possible to open the editor as an administrator and then open the corresponding file modification.
next to Focus, modify the default build project!
here with the MFC new project For example, first we want to find the template path (find me very bitter, this article helped a lot) if the English version in this path:"C:\Program Files (x86) \microsoft Visual Studio 12.0\vc\vcwizards\appwiz\mfc\application\templates\1033", Chinese version in this path: "C:\Program Files (x86) \microsoft Visual Studio 12.0\vc\vcwizards\appwiz\mfc\application\templates\2052" , of course, as above, if your VS is not installed with the default path or not 2013, the path will be slightly different. After finding the path, everything is going to be a lot more, in the Chinese version, for example, the. h and. cpp files in the path shown above correspond to those files created by default for the new project, where "Dialog.cpp" corresponding to each of the project's default generated message response function files, that is, "XxxDlg.cpp" This file, we can modify the contents of the content to enrich our new project function, For example, add the following code below the OnInitDialog function:
#ifdef _debug::allocconsole ();//Open the console resource file *fp;freopen_s (&FP, "conout$", "w+t", stdout);//apply for write, this is for VS2013 version of the code , in the earlier version of VS, such as VS2008, you can change the freopen_s to Freopen, and change the parameter to the corresponding form #endif
in this way, each project in debug mode can pop up a console-like terminal to print debugging information. As for how to customize other functions, it is no longer here to repeat, the operation is generally ibid.
MFC modifies default build files and default build project content