0

In our 32-bit Windows MFC application we use IWebBrowser2 to display HTML content. We also (because MFC does it for us and we're running on Windows 10) use the new IFileDialog COM interface to the common file open dialog.

When we have a web browser window visible in the application, the file dialog will not open, or will open once but never again unless you run the application down and back up again. What usually happens is that this MFC call:-

 HRESULT hr = (static_cast<IFileDialog*>(m_pIFileDialog))->Show(m_ofn.hwndOwner);

simply returns "0x800704c7 The operation was canceled by the user" without even displaying the dialog.

Closing the HTML view/window allows the IFileDialog to work as expected, so the two components seem to be interfering with each other in some way.

This is now happening with software we haven't changed for months, and it seems only to be restricted to Windows 10, but we can find nothing online that gives any clues about the cause.

David.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
Westie
  • 1
  • 1
  • 2
    That is not much to go by. IFileDialog is troublesome on a dirty machine, dev machines in particular usually have a lot of wonky shell extensions installed. You'll have to do the legwork and test this on other machines, the more virgin the better. If it turns out to be machine-specific then aggressively cleaning up extensions with Sysinternals' AutoRuns is the cure. – Hans Passant Oct 27 '17 at 14:33
  • I suggest testing with a fresh Windows install in a virtual machine. Using the snapshot feature of a VM, it takes just seconds to fire up the OS and do some quick testing. Really invaluable for such cases. – zett42 Oct 27 '17 at 19:40
  • We've been using VMs (Hyper-V) for testing already. For example I have a clean vanilla Win10 VM where I have just installed our software, and it exhibits exactly the same issue. Apart from some drivers (NVIDIA, SIS, etc.) and things like codecs there is nothing showing in Autoruns that isn't pre-installed by Microsoft. – Westie Oct 30 '17 at 08:57
  • Another odd thing is that having built a new MFC SDI and MDI app which use CHtmlView as their view class, those work just fine and allow the file dialog to work. This makes me wonder if there are some subtle build issues here which mean our main app is in a slightly different state. Its a much bigger app of course (1 exe and over 60 DLLs) but intrinsically its still an MFC MDI application. – Westie Oct 30 '17 at 09:00

1 Answers1

0

I have the answer to this. a) Your syntax for calling ->Show() is all wrong. b) There are nested guards in the include file 'shobjidl.h' that are blocking processing of the definitions for IFileDialog COM classes, hence many people have been getting compilation errors, unable to generate that elusive output .exe

Essentially all you need when calling the ->Show method is the following loc:

HRESULT hr = pFileDialog->Show(NULL);

See the explanation & example program at:

https://github.com/InventorDave/IFileDialog-gcc-Fix