Home > Software engineering >  The Run - Time Check Failure # 2 - Stack around the variable 'InitCtrls' was corrupted.
The Run - Time Check Failure # 2 - Stack around the variable 'InitCtrls' was corrupted.

Time:09-20

After adding this function, point closed software will pop-up prompts the Run - Time Check Failure # 2 - Stack around the variable 'InitCtrls' was corrupted.
Don't know where the seams
Void progress: : OnBnClickedOk ()
{
//TODO: add the control notification handler code
CStdioFile myFile.
CFileException fileException;
If (myFile. Open (_T (" D: \ \ new folder (5) \ \ MFCApplication11 \ \ MFCApplication11 \ \ progress. TXT "), CFile: : typeText | CFile: : modeReadWrite), & amp; FileException)
{
MyFile. SeekToBegin ();
Cstrings vx.


While (myFile. ReadString (ag))
{
M_edith. SetSel (1);//edit frame orientation to the end of the
Vx. The Format (L "% s \ r \ n", vx);
M_edith. ReplaceSel (ag);
}
}
The else
TRACE (" Can 't open the file % s, error=% u \ n ", _T (" D: \ \ new folder (5) \ \ MFCApplication11 \ \ MFCApplication11 \ \ progress. TXT "), fileException. M_cause);
MyFile. Close ();
}

CodePudding user response:

Try adding a intermediate variable
 cstrings vx2; 
Vx2. The Format (L \ r \ n "% s", (LPCTSTR) vx);
M_edith. ReplaceSel (vx2);


CodePudding user response:

reference 1st floor zgl7903 response:
add an intermediate variable try
 cstrings vx2; 
Vx2. The Format (L \ r \ n "% s", (LPCTSTR) vx);
M_edith. ReplaceSel (vx2);
or no

CodePudding user response:

InitCtrls surrounding code posted to see

CodePudding user response:

Tried, do not have what problem, the code also do not have what problem, I think is in other parts of the affair

CodePudding user response:

reference zgl7903 reply: 3/f
InitCtrls surrounding code posted to see
BOOL CMFCApplication11App: : InitInstance ()
{
//if a run on Windows XP applications listing specified to
//use ComCtl32. DLL version 6 or higher to enable visual way,
//need InitCommonControlsEx (), otherwise, will not be able to create a window,
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls. DwSize=sizeof (InitCtrls);
//set it to include all want to use in your application of
//the control class,
InitCtrls. DwICC=ICC_WIN95_CLASSES;
InitCommonControlsEx (& amp; InitCtrls);

CWinApp: : InitInstance ();


AfxEnableControlContainer ();

//create the shell manager in case the dialog box contains
//any shell or shell tree view control list view controls,
CShellManager * pShellManager=new CShellManager;

//activate Windows "Native" visual manager, so that in the MFC controls enable topic
CMFCVisualManager: : SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerWindows));

//initialize
//if you do not use these features and wish to reduce the
//the size of the final executable file, you should remove the following
//don't need the specific initialization routines
//change is used to store Settings registry keys
//TODO: should be appropriate to modify the string,
//such as modification for the company or organization name
SetRegistryKey (_T (" application wizard to generate local application "));

CMFCApplication11Dlg DLG.
M_pMainWnd=& amp; DLG.
INT_PTR nResponse=DLG. DoModal ();
If (nResponse==IDOK)
{
//TODO: when placed in the treatment with
//"ok" to close the dialog box code
}
Else if (nResponse==IDCANCEL)
{
//TODO: when placed in the treatment with
//"cancel" to close the dialog box code
}
Else if (nResponse==1)
{
TRACE (traceAppMsg, 0, "warning: failed to create dialog, the application will terminate unexpectedly, \ n");
TRACE (traceAppMsg, 0, "warning: if you are to use the MFC dialog box controls, there is no # define _AFX_NO_MFC_CONTROLS_IN_DIALOGS, \ n");
}

//remove the shell created above manager,
If (pShellManager!=NULL)
{
The delete pShellManager;
}

//because the dialog box is closed, so will return FALSE to exit the application,
//rather than start the application's message pump,
return FALSE;
}

CodePudding user response:

I'm just in a dialog box to create classes, then edit box shows TXT, feel other place also no problem

CodePudding user response:

Has now become a "DLG" has a problem now

CodePudding user response:

The suspect part of blocked try
Focusing on strcpy memcpy p++ etc.

CodePudding user response:

refer to the eighth floor zgl7903 response:
the suspect part of blocked try
Focusing on strcpy memcpy p++ etc.
I try

CodePudding user response:

Stack of normal around XXX is caused by memory be destroyed.

Since dialog classes generated code is part of the problem, it means that either library version is wrong, or your subsequent code, destroyed the variables in memory

CodePudding user response:

Set this variable InitCtrls to static can be solved, such as static char InitCtrls [x];
  • Related