PRB: CFileDialog::DoModal() Does Not Display FileOpen Dialog

Last reviewed: January 15, 1998
Article ID: Q131225
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) included with: - Microsoft Windows 95 version 4.0

SYMPTOMS

Calling CFileDialog::DoModal() returns without displaying the FileOpen common dialog.

CAUSE

The CFileDialog class will automatically use the new Explorer-style FileOpen common dialog under Windows 95. This can break existing code which customizes these dialogs with custom templates, because the mechanism has changed in Windows 95.

NOTE: This does not apply to Windows NT 3.51, as this version of Windows NT will not display the new Explorer-style dialog.

RESOLUTION

An application that depends on the old behavior of customizing the File Open common dialogs will need to reset the OFN_EXPLORER bit in the Flags member of the OPENFILENAME structure before calling CFileDialog::DoModal.

MORE INFORMATION

The DIRPKR sample in particular, exhibits the symptoms described above, and will need to be modified to display the dialog box correctly in Windows 95. It works as is under Windows NT 3.51.

Sample Code

    CMyFileDlg  cfdlg(FALSE, NULL, NULL, OFN_SHOWHELP | OFN_HIDEREADONLY |
                      OFN_OVERWRITEPROMPT | OFN_ENABLETEMPLATE,
                      NULL, m_pMainWnd);

    cfdlg.m_ofn.hInstance      = AfxGetInstanceHandle();
    cfdlg.m_ofn.lpTemplateName = MAKEINTRESOURCE(FILEOPENORD);
    cfdlg.m_ofn.Flags         &= ~OFN_EXPLORER;

    if (IDOK==cfdlg.DoModal())
    {
      :
      :
    }


NOTE: For versions of Visual C++ 2.x, the OFN_EXPLORER flag has not been defined. You can use this code instead:

    cfdlg.m_ofn.Flags &= ~(0x00080000);

REFERENCES

This information was derived from Visual C++ 2.1 Technical Note 52: "Writing Windows 95 Applications with MFC 3.1"

Keywords          : UsrCmnDlg kbui
Technology        : kbMfc
Version           : 4.0
Platform          : WINDOWS
Issue type        : kbprb


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: January 15, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.