Link to home
Start Free TrialLog in
Avatar of boomshanker
boomshanker

asked on

Windows 2000 style File Dialog box

I'm just starting out with MFC and I'm wondering if there is a way to display the Win 2000 style dialog box instead of using the older style.

Here is the code I am using now:


void CSTUploadDoc::OnDataImport()
{
     TCHAR buffer[] = _T("Dat Files (*.dat)|*.dat|All Files (*.*)|*.*||");
     CFileDialog dlg(TRUE, _T("dat"), _T("*dat"), OFN_FILEMUSTEXIST, buffer);

     if (dlg.DoModal() == IDOK) {
          try {
               CStdioFile f(dlg.GetPathName(),CFile::modeReadWrite);
               LoadData(f);
          }
          catch (CFileException *e) {
               e->ReportError();
               e->Delete();
          }
     }
}




Any help would be greatly appreciated.
Thx.
Avatar of migel
migel

Hi!
To use Win2K style dialog you have to set correct CFileDialog.m_ofn.lStructSize = sizeof(lStructSize)+3*sizeof(DWORD);
before calling DoModal;
I assume that your project doesn`t contain defines such as
_WIN32_WINNT = 0x0500;
Avatar of boomshanker

ASKER

Thanks for your response.

Could you possibly show me how to implement that with the code I have?

If I use the code you supplied as follows:

dlg.m_ofn.lStructSize = sizeof(lStructSize)+3*sizeof(DWORD);

I get an "lStructSize Undeclared Identifier" error upon compile.

How do I declare lStructSize?  Do I have to set any other data members of the struct?

Thank you in advance for any further help you may offer.
ASKER CERTIFIED SOLUTION
Avatar of migel
migel

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That's great!

Thank you so much for your help, and your quick response.
Much appreciated.