FIX: You encounter an access violation when you use a CFileDialog dialog box created from the handler of a custom CFileDialog dialog box in Visual C++ 6.0 (256329)



The information in this article applies to:

  • Microsoft Visual Studio 6.0 SP1, when used with:
    • the operating system: Microsoft Windows 2000
  • Microsoft Visual C++, 32-bit Professional Edition 6.0
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0

This article was previously published under Q256329

SYMPTOMS

When you create a CFileDialog dialog box from the handler of a custom CFileDialog dialog box, an access violation can occur.

CAUSE

This problem is caused by a bug in the Microsoft Foundation Classes (MFC). When the second CFileDialog object is created, the m_pAlternateWndInit data member in the thread state is set, so that the _AfxCommDlgProc routine can hook up the HWND handle of the second dialog box to the second CFileDialog object. Another message is sent, however, from the first CFileDialog object, and this first object is subclassed instead of the second one. The dlgproc routine of the first CFileDialog object calls itself recursively, which leads to a stack overflow. This problem occurs whenever two CFileDialog objects are instantiated concurrently.

RESOLUTION

The Mfc42.dll and Mfc42u.dll files that are included with Microsoft Windows 2000 incorporate a fix for this problem.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section. This bug was corrected in the latest service pack for Visual Studio 6.0.

For more information about Visual Studio service packs, click the following article numbers to view the articles in the Microsoft Knowledge Base:

194022 INFO: Visual Studio 6.0 Service packs, What, Where, Why

194295 HOWTO: Tell That a Visual Studio service Pack Is Installed

To download the latest Visual Studio service pack, visit the following Microsoft Web site:

MORE INFORMATION

Steps to reproduce the behavior

  1. Create an MFC application with a custom CFileDialog dialog box.
  2. From the button handler of this dialog box, create a regular CFileDialog dialog box. For example:
    CMyFileDialog::OnButton1()
    {
       CFileDialog dlg(TRUE);
       dlg.DoModal();
    }
    					
  3. Rebuild and run the application.
  4. Open the custom dialog box, click the button to open the second dialog box, select a file, and then click Open.

Modification Type:MinorLast Reviewed:12/12/2005
Keywords:kbtshoot kbMFC kbBug kbCmnDlg kbfix kbVC600fix kbVS600sp4fix kbVS600sp5fix KB256329 kbAudDeveloper