Please read my blog's comment policy here.
Because the WebBrowser Control (WebOC) can be used to display a wide range of content (HTML, Office Documents, PDFs, the local file-system, etc) it is often integrated into applications as a somewhat generic object hosting surface. For Windows 7, a small change was made that will impact applications that use the WebOC to allow the user to explore the local file system.
By way of example, here’s a trivial little WebOC host which displays the Windows folder:
On Windows Vista and below, the user may double-click on a folder to navigate the WebOC to that folder, like so:
However, on Windows 7, double-clicking on the folder will open a Windows Explorer window instead:
The change in behavior exists because of a small change made in the Windows 7 Shell. Specifically, the filesystem viewing object will not navigate in-place unless the host container supports SID_SInPlaceBrowser, which is defined in the Windows 7 SDK (see shlguid.h). By default, the WebBrowser control’s QueryService implementation does not support SID_SInPlaceBrowser, so the filesystem viewing object will launch a new Windows Explorer instance when the user double-clicks on a folder in the WebOC.
For WebOC-hosting applications that are impacted by this change, two workarounds are available.
Windows Vista’s Shell introduced a new control which implements the IExplorerBrowser interface; this is the recommended method of hosting a Windows Shell filesystem view within your application. Developers building applications using .NET can use the wrapped version of the ExplorerBrowser control available in the Windows API CodePack for .NET.
Please note that this interface is only available on Windows Vista and later. If your application needs to run on earlier Windows versions, you will need to fallback to the old WebOC implementation on those platforms.
As noted in the previous section, using the ExplorerBrowser control is the supported and recommended method for hosting a filesystem view within your application.
Having said that, you may be able to make a small change to your application to enable the filesystem object to navigate in-place within the WebOC when running on Windows 7. To do so, your hosting application will implement the IServiceProvider interface, and hand back the WebBrowser control’s SID_SShellBrowser when asked for SID_SInPlaceBrowser:
1: // IServiceProvider
2: IFACEMETHODIMP QueryService(__in REFGUID guidService, __in REFIID riid, __deref_out void **ppv)
4: *ppv = NULL;
5: HRESULT hr = E_NOINTERFACE;
6: if (guidService == SID_SInPlaceBrowser)
8: hr = IUnknown_QueryService(_spBrowser, SID_SShellBrowser, riid, ppv);
10: return hr;
By doing this, the filesystem viewer object will believe its host supports SID_SInPlaceBrowser and will navigate in place as the user double-clicks on folders.
Happy New Year, and thanks for reading! IEInternals is now just over seven months old, and this is post #63. I’m confident that next year, I’ll have even more to share. :-D
Update 3/14/2011: Workaround #3: Install IE9 on the affected client. IE9 RC included a fix for this issue (basically, Workaround #2 is built into IE itself).
Unfortunately, if you are using the webOC in an Office app like Access, then this minor change stuffs things up! It's a shame that the webOC is not updated to at least respond as in Workaround # 2 if an IE registry flag is set for a particular app - at least then existing apps would continue to work as designed.
Are these screenshots made with Windows Clippings?
@Huns: I use three tools for screencaptures: The Windows Snip tool, NTWind's WinSnap, and my own Mezer Tools (www.bayden.com/mezer). I suspect I used at least two of those for these screenshots.
Why do you ask?
I guess I am not an actual software developer because I have no clue what is meant by workaround #2. Where is this code change made and how do I change it? That would be really helpful for newbies like myself that have been using built in controls for the past 5 years.
@Chris, without more details, I cannot possibly help you. What language/technology are you using?
Sorry about that. I am using Visual Studio 2008 and am programming using Visual Basic. The issue I am having is my current application uses the WebBrowser.Navigate function to display PDF documets on the local intranet. With windows XP they would show up in the browser. Now, however, they open up within Adobe Acrobat Reader instead. The application was designed to offer tabbed browsing similar to Internet Explorer. I have checked Adobe setting and verified that with the same version of Adobe on XP systems produces the desired results. Thanks for the reply.
I have 2 questions about IExplorerBrowser Interface:
1- Is ExplorerBrowser included in Vista by default? I mean, do i still need to install "Windows® API Code Pack for Microsoft® .NET Framework" though having Vista?
2- Will i be able to get some arguments via "Explorer Browser(IExplorerBrowser Interface"), such as the file path of right-clicked file AND the file path of which is goring to be dragged-and-dropped?
Please let us know,
@onur: The ExplorerBrowser is a COM component that ships with Vista. The API pack is simply a wrapper that simplifies calling that object from .NET. As for the capabilities of the ExplorerBrowser component, I have no idea what it supports. You should check the documentation.
I have a problem very much like Chris's: Visual Studio 2008 (Visual Basic) + WebBrowser containing Excel worksheet, which worked in WindowsXP excellent.
In Windows7 a new Excel window is opened instead. What could be done? Any ideas will be appreciated.
@Nina: The issue with hosting Office Applications is not really related to the issue with hosting Windows Explorer. Which version of Office? See support.microsoft.com/.../927009 and support.microsoft.com/.../304662.
Due to the first link (support.microsoft.com/.../927009) I've updated registry for Excel entries and received
Excel in the WebBrowser control and not in the separate window.
Could we get Workaround #2 in VB?
@RedsGT: Sorry, I have no idea how to do this in VB. The good news is that this issue is resolved when IE9 is installed on the computer.