简体   繁体   中英

IWebBrowser2 blocks IFileDialog

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM