Microsoft KB Archive/256329

= 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 =

Article ID: 256329

Article Last Modified on 8/7/2007

-

APPLIES TO


 * Microsoft Visual Studio 6.0 Service Pack 1, when used with:
 * Microsoft Windows 2000 Standard Edition
 * Microsoft Visual C++ 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



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:

http://msdn2.microsoft.com/en-us/vstudio/Aa718353.aspx



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

Additional query words: sp4

Keywords: kbtshoot kbmfc kbbug kbcmndlg kbfix kbvc600fix kbvs600sp4fix kbvs600sp5fix KB256329

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.