An unhandled exception at XX: 0xC0000005: Access conflict occurs when the read location is 0x00000020.
This exception is often encountered during the debugging of the mfc program. At the beginning, I didn't know how to deal with the problem. Later I encountered more times and found that this problem is generally easy to find the cause.
For example, the following dialog box contains an edit box control and two button controls, one for hiding the edit box and the other for displaying the edit box. The processing code for these two buttons is simple:
GetDlgItem (IDC_EDIT1)-> ShowWindow (FALSE); and
GetDlgItem (IDC_EDIT1)-> ShowWindow (TRUE );
However, during the encoding process, we found that this edit box was not required, so we deleted it. But the code in the previous two buttons was not deleted. (This is just for simple restoration or for the above exceptions. Of course, in actual work, the cause will certainly not be so simple .)
Continue to debug the program. When you click "Hide dialog box", an exception occurs. (In practice, this exception is often caused by sending a Windows message, switching between different dialog pages, or closing the dialog box ).
The arrow is indicated in ASSERT (: IsWindow (m_hWnd) | (m_pCtrlSite! = NULL ));
Through this ASSERT of IsWindow, it is clear why such an exception occurs. Where has ShowWindow been called? Click "interrupt" and open the "call stack" window.
Observe the 2nd rows and double-click it.
The Code locates the Cbug_detectDlg: OnBnClickedButton2 () function:
At this time, we will realize that the edit box with ID IDC_EDIT1 has been deleted. How can we use ShowWindow? It must have an exception. This mistake will certainly not be done by the experts or it will be easy to handle. I will wait for the dishes to learn more and accumulate more.