0

In Visual Studio 2015 the File Dialog used by the IDE looks like this:

File Dialog

In my MFC application, when I use a CFileDialog, example:

CFileDialog dlgImport(TRUE,
    _T(".XSL"), _T(""), OFN_ALLOWMULTISELECT | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, strFilter, this);

My version is not the same:

MFC File Dialog

I like how the Visual Studio version shows the file type as wider control. Much neater.

How can I implement this behaviour?

Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
  • 1
    I think, but I'm not positive, that Visual Studio uses a custom file open dialog. I *know* Office does. – Mark Ransom Dec 14 '16 at 15:20
  • @MarkRansom Why don't they make it available for users of their application? Would have been great. – Andrew Truckle Dec 14 '16 at 15:26
  • 4
    Visual Studio is actually using an *older* version of the dialog. The new dialog has the file-type combobox off to the right. Open Notepad or any other app bundled with the system and you'll see this is what it looks like. This is the new [Common Item Dialog](https://msdn.microsoft.com/en-us/library/windows/desktop/bb776913.aspx), introduced with Vista. Visual Studio is using the old-school dialog, shown by calling [`GetOpenFileName`](https://msdn.microsoft.com/en-us/library/windows/desktop/ms646927.aspx). Of course, it uses `OFN_EXPLORER`, and may have custom logic extending it, too. – Cody Gray - on strike Dec 14 '16 at 15:59
  • @CodyGray That explains it. Perhaps you should add that as the answer? – Andrew Truckle Dec 14 '16 at 16:12
  • @MarkRansom How do you know? – sergiol Dec 15 '16 at 00:26
  • Did you dive into the file dialog source? IIRC there was a boolean for setting the look, something like `m_bVistaStyle`. If it is private protected you will need to derive a class. – sergiol Dec 15 '16 at 00:32
  • https://msdn.microsoft.com/en-us/library/dk77e5e7.aspx – Andrew Truckle Dec 15 '16 at 02:55
  • As per the link, that bool variable is set via the constructor. Last parameter. – Andrew Truckle Dec 15 '16 at 03:15

0 Answers0