This documentation is archived and is not being maintained.


m_ofn is a structure of type OPENFILENAME. The data in this structure represents the current state of the CFileDialog.

Use this structure to initialize the appearance of a File Open or File Save As dialog box after you construct it but before you display it with the DoModal method. For example, you can set the lpstrTitle member of m_ofn to the caption you want the dialog box to have.

With the Windows Vista style of CFileDialog, m_ofn is not guaranteed to always match the state of the dialog box. It is synchronized with the dialog box in earlier versions of Windows. See CFileDialog::ApplyOFNToShellDialog and CFileDialog::UpdateOFNFromShellDialog for more information about synchronizing the m_ofn structure and the CFileDialog state under Windows Vista.

Windows Vista style file dialogs do not support certain members and flags of the CFileDialog. As a result, these will have no effect.

The following is a list of the members that are not supported by Windows Vista:

  • lpstrCustomFilter

  • lpstrInitialDir

  • lCustData

  • lpfnHook

  • lpTemplateName

The following flags are not supported and therefore have no effect when you use the Windows Vista style of CFileDialog:








  • OFN_LONGNAMES - effectively always on in Windows Vista

  • OFN_NOLONGNAMES - effectively always off in Windows Vista

  • OFN_NONETWORKBUTTON - effectively always on in Windows Vista



For more information about this structure, see the OPENFILENAME structure in the Windows SDK. For more information about the different behavior of the CFileDialog under Windows Vista, see CFileDialog Class.

Header: afxdlgs.h