Summary of VC FAQs (1)

Source: Internet
Author: User

1: Fatal error c1010: unexpected end of file while looking for precompiled header Directive
If the file with an error is added to the current project by another C code file, ALT + F7 will enter the settings of the current project, and select the C/C ++ tab, select precompiled headers from the category combo box and not using precompiled headers. OK
If the file in which the error occurs is originally in this project, check whether there is a # include "stdafx. H" statement in the file header. If not, add it.
If not, it may be that the defined class or struct has forgotten the extra points.
2: Fatal error rc1015: cannot open include file 'afxres. H'. How can this problem be solved?
# Include "afxres. H "statement is in. in the RC file, while afxres. the H file is in the installation directory of VC. in the/vc98/mfc/include directory, check whether the directory containing files in the Options dialog box in the Tools menu is correct and whether the directory is in the installation path of the VC. If not, if there is no problem, copy afxres to other machines. H to the corresponding directory
3: The DLL-allocated memory block is released by the application and an exception is reported.
Replace new with globalalloc () and replace Delete with globalfree ().
In fact, there is another way to change the use run-time liberary of the code generation on the C/C ++ Tab Of the DLL settings to debug multithreaded DLL, and change it to multithreaded DLL in the release version, you can use new and delete directly. No problem.
Generally, the DLL-allocated memory is released by the DLL. Isn't it better to add a function in the DLL to release the memory.
4: I found that the print preview image is significantly smaller than the screen display image. What should I do?
Most of these are caused by the selection of the CDC ing mode. By default, mm_text mode is selected. mm_text is measured in pixels of the device, while the pixels of different devices are of different sizes, the resolution of the printer is much higher than that of the monitor, which causes the same image to become smaller during printing. The solution is to use other fixed-length ing modes, such as mm_himetric (CDC: setmapmode () to change the ing mode)
5: cstring, char *, String, Int, _ bstr_t, ctime, coledatetime, etc. How can I determine whether a string is a floating point number?

# Include <string>
Using namespace STD;
# Include <comdef. h>

{
Cstring strcstring = "ABC ";
Char strchar [256], * pstr;
 
Pstr = (lpstr) (lpctstr) strcstring; // cstring ----> char *
Strcpy (strchar, (lpstr) (lpctstr) strcstring); // cstring ----> char []
 
_ Bstr_t strbstr = pstr; // char * ----> _ bstr_t
Wchar * strwchar = strbstr; // B _str_t ---> Unicode

Strbstr = strwchar;
Pstr = strbstr; // Unicode ----> char *

Strcstring = "10 ";
Int istr = atoi (lpstr) (lpctstr) strcstring); // cstring, char [], char * ------> int
Strcstring. Format ("% d", istr); // int -----> cstring
Sprintf (strchar, "% d", istr); // int -----> char []
 
Pstr = new char [256]; // string request Space
Strcpy (pstr, "ABC"); // string value assignment
Delete [] pstr; // string release
 
String strstring = "ABC ";
Pstr = (char *) strstring. c_str (); // string ----> char *

Strcstring = "6:24:37"; // cstring ---> coledatetime
Colevariant vtime (strcstring );
Vtime. changetype (vt_date );
Coledatetime time4 = vtime;
 

Coledatetime time1 (1977,4, 16,2,); // coledatatime ---> ctime
Systemtime receivime;
Varianttimetosystemtime (time1, & systime );
Ctime TM (systime );

Time_t time2 = TM. gettime (); // ctime ---> time_t
Coledatetime time3 (time2); // time_t ---> coledatetime

// Determine whether the string is of a certain type
Cstring svalue ("123.1 ");
Colevariant vvalue (svalue );
 
Bool bstrisfloat = (succeeded (variantchangetype (& vvalue, & vvalue, 0, vt_r8) & svalue. Find ('.')! =-1 );
If (bstrisfloat)
{
Afxmessagebox ("Floating Point ");
}
}

6: How to Create a unicode application?

Create an application, open the Alt + F7 settings option, select the C/C ++ tab, and add _ Unicode in Preprocessor definenation. On the link tab, select output in the Category Selection box, in the entry-point symbol edit box, add wwinmaincrtstartup.

Note that when debugging Unicode programs, you need to select all options for VC during installation; otherwise, the dynamic library and the corresponding. Lib file will be missing.

7. An error occurred while updating the database tables through ADO.
Before opening the database, add the following statement to try precordset-> cursorlocation = aduseclient;

 

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.