The ShowWindow function generates the following error: "unprocessed exception at XX: 0xC0000005: Access conflict occurred when the read location is 0 × 00000020"

Source: Internet
Author: User

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.

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.