Skills and problems in using VC ++

Source: Internet
Author: User
<Partially transferred from Tianji>

1. During database operations, replace the ctime automatically generated by the system with coledatetime.

2. When operating the ACCESS database, the string identifier is single quotation marks; the date/time identifier is :#

3. Replace ddx_fielddatetimectrl (PDX, idc_publishdate, m_pset-> m_publishdate, m_pset):
Ddx_datetimectrl (PDX, idc_publishdate, m_pset-> m_publishdate );
Note: This is an old bug in vc6, as in sp6.

4. When a class in classview is suddenly lost, you can delete the two files with the extension. NCB and. Opt in the project folder and re-open the project.
When the member functions under the class are not correctly located, that is, when you double-click the function and cannot accurately locate the specified position, you can debug or release (depending on the mode you selected at the time) the extension is :. delete the PCH file. If not, delete the above two files together. No, I am not sure. So I suggest you go out, shouting at the sky: "God, please help me!"

5. If you really like the auto-complete function of vc6 and find that it is in conflict with the CTRL + space input method of the system, we suggest the following:
Menu "Tools"-> "customize"-> "keyword", select "All commands", click "All commands", and tap "comple... "and then add a" Shift + space "and assign to the right.
Vc6 is better than DELPHI6. In DELPHI6 and later versions, the autocomplete function is already very good. Of course, in earlier versions, what is the slowness of AutoComplete, however, unfortunately, I have not found a place where I can customize shortcuts. It seems that I can only use "Ctrl + space". Which of the following prawns knows how to tell me? In addition, I can use Ctrl + J in DELPHI6, this is not in vc6, but it is enough to install visual extension 6.

6. We recommend that you use the keyword color custom function edited by vc6, or you can use Visual 6 to enable the color function. Even if you do not like the custom color, there is a color, I suggest you customize it:
Menu "Tools"-> "options"-> "format"
Color: Number Foreground: Red, otherwise it is easy to mix: '0' and 'O', especially in the default font of vc6.

7. Check whether the brackets in the program match
Move the cursor to the brackets to be checked (such as braces {}, square brackets [], Parentheses (), and angle brackets <>), and press Ctrl +]. If the brackets match correctly, the cursor jumps to the matching brackets. Otherwise, the cursor does not move and the chassis horn generates a warning.
[Note: when the content of a function body is too long to be selected, you can move the cursor to the {position of the function body and press Ctrl +} to select all]

8. View macro definitions of a macro (or variable or function)
Move the cursor to a macro You Want To Know. For example, on the most common declare_map_message, click F12 (or right-click go to defition ...), If browse files is not created, a dialog box is displayed. Click OK. Then, the page jumps to the location where those objects are defined.
[Note: this function is usually used, but it does not feel that the hot key is as fast as the mouse selection.]

9 format a mess of source code
Select the source code and press ATL + F8.
[Note: select a piece of code, press tab, Shift + tab, and right (or left) Move a Tab]

10. The member variables or functions cannot be displayed during editing.
Delete the. NCB file and reopen the project.
[Note: What I said last time is not very accurate. Opt may contain the folder information you created in classview. If you delete the folder information, the category Folder Information is also deleted.]

11. How to organize a large number of classes in the classview
You can right-click the classview view to create a folder (new folder) and drag classes of similar properties to the corresponding folder to make the entire view clear.
[Note: In fact, I also saw folder classification in FileView. My feeling is: it may be to avoid the loss of some of the above functions in classviews, after all, vc6 is sometimes not very stable. Of course, the two methods have their own advantages and disadvantages. I usually prefer the former]

12. Specify the pre-processing position.
Locate the cursor in the source file to symmetric # If, # endif, and use Ctrl + K.

13. How to add Lib in the system to the current project
Enter the Lib name in project development Settings Using link between object/library modules, and use an empty grid to separate lib files.
[Note: Alternatively, # pragma comment (Lib, "yourlib. lib")]

14. How to add the system header file (. h) to the current project.
# Include <FILENAME. h>: indicates to compile the file to the VC system directory. Use # include "filename. H" to find the file in the current directory.

15. How to Use Assembly debugging in Studio
In the workbench debugger status, press Ctrl + F7.

16. How to Handle System messages not found by classwizard
If you want to process system messages such as wm_nchittest in classwizard, change the message filter to window on the class info page of classwizard.
[Note: classwizard uses toponthemost by default.]

17. How to delete a class cleanly
Delete the corresponding. h and. cpp files from the FileView In workspace, close the project, and delete the corresponding. h and. cpp files and. CLW files from the actual folder.

18. If you want the console application to support the MFC class library
You can include the MFC library in the console application, but the console application is single-threaded by default, and the MFC is multi-threaded. To solve this problem, in the project setting-> C/C ++ option, select code generation and select debug multithread in the use run-time library drop-down box.

19.if he Changhua only has an executable code. EXE file
Use VC open file in NT to open the *. EXE file in resources mode, modify the resource file directly, and save the file.
[Note: I usually use exclusive to edit]

Appendix: VC project file description

The. Opt project parameter file for the development environment. Such as the tool bar position and other information;

. APS (appstudio file), Resource auxiliary file, binary format, usually don't worry about it;

. The CLW classwizard information file is actually in the INI file format. If you are interested, please study it. sometimes the classwizard has a problem. You can manually modify the CLW file to solve the problem. if this file does not exist, you will be prompted to re-create it each time you use classwizard;

. DSP (workflow studio project): A project file in the text format. If you are not familiar with it, Do not manually modify it. DSW (workflow studio workspace) is a workspace file. Other features are similar to those of DSP;

. PLG is a compilation information file. The error and warning information files during compilation (actually an HTML file) are generally of little use. there is an option in tools-> options to control the generation of this file;

. HPJ (help project) is the project for generating help files, which can be processed using microsfot help compiler;

. MDP (Microsoft devstudio project) is an earlier version of the project file. To open this file, you will be prompted to convert it to a new DSP format;

. BSc is used to browse project information. This file is required if source Brower is used. if you do not need this function, you can remove the generate browse info file in project options to speed up compilation;

. Map is the image information record file of the execution file, unless you are very familiar with the underlying system, this file is generally not needed;

. PCH (pre-compiled file) is a pre-compiled file, which can speed up compilation, but the file is very large;

. PDB (Program database) Records Program-related data and debugging information, which may be useful during debugging;

. Exp is generated only when the DLL is compiled, and some information in the DLL file is recorded. It is generally useless;

. NCB does not compile the browsing file (No compile browser ). You can delete this file when the Automatic completion function fails. It is automatically generated after build.

 

 

 

Link error lnk2001 of VC ++

When learning VC ++, you will often encounter a link error lnk2001, which is very annoying, because for programmers, the best mistake to change is the compilation error. In general, when a connection error occurs, compilation is successful. There are many causes of connection errors, especially lnk2001 errors, which are often unknown. If you do not thoroughly learn and understand VC ++, it is very difficult to correct the connection error lnk2001.
When a beginner is learning VC ++, The lnk2001 error message is as follows:
Unresolved external symbol "symbol" (uncertain external "symbol ").
This error message is generated if the connection program cannot find the referenced function, variable, or tag in all the libraries and target files. In general, there are two reasons for the error: first, the referenced function, the variable does not exist, the spelling is incorrect, or the usage is incorrect. Second, different versions of the Connection Library may be used.
The following are possible causes of lnk2001 errors:
1. lnk2001 due to an Encoding Error.
1. mismatched program code or module definition (. Def) files can cause lnk2001. For example, if a variable "var1" is declared in the C ++ source file, but an attempt is made to access the variable "var1" in another file, this error occurs.
2. If the inline function is defined in the. cpp file, rather than being defined in the header file, the lnk2001 error will occur.
3. When a function is called, if the parameter types used do not match the type declared by the function, lnk2001 is generated.
4. lnk2001 will occur when you try to call a virtual function from the constructor or destructor of the base class.
5. Pay attention to the availability of functions and variables. Only global variables and functions are public.
Static functions and static variables have the same scope of use. When attempting to access any static variables not declared in the file from outside the file, it will cause a compilation error or lnk2001.
Variables declared in the function (local variables) can only be used within the scope of the function.
The global constants of c ++ only have static connection performance. This is different from C. If you try to use global variables in multiple files in C ++, lnk2001 errors will also occur. One solution is to add the initialization code of the constant to the header file when necessary, and. the CPP file contains this header file. Another method is to assign a constant to the variable during use.
Ii. lnk2001 caused by compilation and link settings
1. if the/nod (/nodefalib Lib) option is used during compilation, the compiler writes the Runtime Library and the MFC Library required by the program to the target file module during connection, however, these libraries will not be linked to the project file unless they are explicitly included in the file. In this case, using/nod will cause the error lnk2001.
2. If no program entry is set for wwinmaincrtstartup, the "unresolved external on _ winmain @ 16" lnk2001 error message will be obtained when Unicode and MFC are used.
3. when compiling with the/MD option, since all runtime libraries are retained in the dynamic link library, the source file references "func, reference "_ imp _ FUNC" in the target file. If you try to use the static library libc. lib or libcmt. when Lib is connected, lnk2001 will occur on _ imp _ FUNC. If the/MD option is not used for compilation, msvcxx will be used. lnk2001 also occurs during lib connection.
4. When compiling with the/ml option, lnk2001 occurs on _ errno if libcmt. Lib is used.
5. lnk2001 is generated when the release modal library is used for the compilation and debugging of the application. Similarly, the same problem occurs when you use the debug modal library to connect to the release application.
6. Mixed use of libraries and compilers of different versions can also cause problems, because the new library may contain symbols and descriptions not available in earlier versions.
7. using inline and non-inline compilation options in different modules can lead to lnk2001. If function inline (/ob1 or/ob2) is enabled when the C ++ library is created, but function inline (no inline keyword) is disabled in the header file that describes the function ), the error message is displayed. To avoid this problem, use the inline keyword to mark the inline function in the corresponding header file.
8. Incorrect/subsystem or/entry settings can also lead to lnk2001.
In fact, there are still many reasons for lnk2001. The above reasons are only part of them. For Beginners, these are enough to understand for a while. However, the purpose of analyzing error causes is to avoid errors. Although the lnk2001 error is difficult, the above problems can be avoided and solved as long as they are noticed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.