刚写的程序,我在给CEDIT控件添加一个变量、设置其大小,然后运行程序就显示溢出了,请各位高人给点指点。
这也是个小问题,希望大家多多指点,回答就给分。

解决方案 »

  1.   

    谢谢 以上两位的回答,本来我的程序没有任何异常,但是我当我给一个CEdit控件添加变量:头文件:public:
    CString ert;.cpp文件中:DoDataExchange函数中:添加
    DX_Text(pDX, IDC_EDIT1, ert);
    DDV_MaxChars(pDX, ert, 2084);
    完成以上修改程序后
    在程序退出时 会跳出以下异常:
    Run-Time Check Failure #2 - Stack around the variable 'dlg' was corrupted
      

  2.   

    MSDN上面找的
    好好看看第三段CString
    CString does not have a base class.A CString object consists of a variable-length sequence of characters. CString provides functions and operators using a syntax similar to that of Basic. Concatenation and comparison operators, together with simplified memory management, make CString objects easier to use than ordinary character arrays. CString is based on the TCHAR data type. If the symbol _UNICODE is defined for your program, TCHAR is defined as type wchar_t, a 16-bit character type; otherwise, it is defined as char, the normal 8-bit character type. Under Unicode, then, CString objects are composed of 16-bit characters. Without Unicode, they are composed of 8-bit char type.When not using _UNICODE, CString is enabled for multibyte character sets (MBCS, also known as double-byte character sets, DBCS). Note that for MBCS strings, CString still counts, returns, and manipulates strings based on 8-bit characters, and your application must interpret MBCS lead and trail bytes itself.CString objects also have the following characteristics: CString objects can grow as a result of concatenation operations.
    CString objects follow “value semantics.” Think of a CString object as an actual string, not as a pointer to a string. 
    You can freely substitute CString objects for const char* and LPCTSTR function arguments.
    A conversion operator gives direct access to the string’s characters as a read-only array of characters (a C-style string). 
    Tip   Where possible, allocate CString objects on the frame rather than on the heap. This saves memory and simplifies parameter passing.CString assists you in conserving memory space by allowing two strings sharing the same value also to share the same buffer space.  However, if you attempt to change the contents of the buffer directly (not using MFC), you can alter both strings unintentionally. CString provides two member functions, CString::LockBuffer and CString::UnlockBuffer, to help you protect your data.  When you call LockBuffer, you create a copy of a string, then set the reference count to -1, which "locks" the buffer. While the buffer is locked, no other string can reference the data in that string, and the locked string will not reference another string. By locking the string in the buffer, you ensure that the string’s exclusive hold on the data will remain intact. When you have finished with the data, call UnlockBuffer to reset the reference count to 1.For more information, see theStrings in MFC andStrings: Unicode and Multibyte Character Set (MBCS) Support articles in Visual C++ Programmer’s Guide andString Manipulation Routines in the Run-Time Library Reference.
      

  3.   

    编译器是VC6.0么难道是VC++.NET
    这样的话建议楼主把DDV_MaxChars(pDX, ert, 2084); 
    改为DDV_MaxChars(pDX, ert, 2083); 
    然后试试
      

  4.   

    我以前遇到过栈溢出的问题,后来把project设置里的堆栈加大就可以了,默认是1M,你可以加大到10M试试.   
      project->setting->link:   
      在category里选择output,在stack的Reserve里输入0x10000000
      

  5.   

    我告诉你:
    在CXXXXApp::InitInstance(){
    ....
    delete m_pMainWnd;
    return false;
    }
      

  6.   

    主把DDV_MaxChars(pDX, ert, 2084); 
    改成
    DDV_MaxChars(pDX, ert, 2083);2083啊