Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


How can I disable OPEN / SAVE / CANCEL dialog in WebBrowser class ?

Posted on 2006-07-24
Medium Priority
Last Modified: 2012-06-21
I'm using the managed WebBrowser control that comes with .Net 2.0 to open office documents like Word and Excel. But before openning the document, it displays an annying warning and asks to the user whether he wants to open/save the document or cancel. I want to disable this message and open the document immediately because this is a document management application and it is safe to open all the documents. My application should not change any of the options in users registry and disabling this warning should be restricted to my browser control in the application. Other explorer windows should not be affected.

Mustafa Kok
Question by:muskok
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
LVL 11

Expert Comment

ID: 17169350
you could find the windowhandle of that dialog by using the win32 api function findwindow and close that window by code, but that is not the best way to my opinion. do you get the same message, if you start such a document from office itself?
could you post a link with a screenshot of that message here?

Expert Comment

ID: 17170365

I've played around with the issue and it looks like it is a security setting in IE. You know that, though. Because of the nature of the managed control, I don't think you have access to this sort of functionality. The closest answer I could come up with was the CoInternetSetFeatureEnabled function in urlmon.dll. However, I couldn't get any combination of parameters to work.

Have you tried adding your site to the browser's trusted sites (via IE's Options)? That would eliminate most of your security concerns with other sites since they would have to have the same URL as your site to bypass this dialog like your site would.

Other than that, I'm unable to come up with anything.


LVL 11

Expert Comment

ID: 17170988
another question, do you have to embed word or excel in ie or is it fine if you implement the office instance directly in your app?
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.


Author Comment

ID: 17173785
Closing the window cannot be the solution because it is opened as dialog and the activex object waits for the user's response to the security question. It simply says that openning files from non trusted zones may be dangerous. It is a generic XP security warning window. I dont know how to add images but you can see the message if you open a blank iexplorer window then drag and drop an Excel file onto it.

Adding a new site to the trusted zones is possible through the IInternetSecurityManager interface, but it is not an option (I considered it before asking this question). Because our application should not touch any of the security settings on client computers, our clients are strict at this point.

I considered embedding word or other applications directly, but it so complex. You have to find the correct application for the given document type (from registry), create correct ActiveX object, add it to your form, pass file to it, close (dispose) it and be sure resources are relesed correctly, otherwise fatal COM exceptions and memory leaks occur. WebBrowser does this for us, but if you have example code that can do these things correctly it may also solve my problem.

This method is useful if you are familiar with OLE development using the unmanaged WebBrowser ActiveX control and you want to extend the functionality of the Windows Forms WebBrowser control, which is a managed wrapper for the ActiveX control. You can use this extensibility, for example, to customize the browser shortcut menu and shortcut keys or to provide a custom security configuration for hosted documents.

I searched MSDN for this issue and I found that it can be done by deriving a new WebBrowser class from the existing one and provide implementations for IDocHostUIHandler, IInternetSecurityManager... But there is no example how to do this. I wrote several different classes but they didn't work.

------- From MSDN -----
To use this feature, implement classes that inherit from the WebBrowser and WebBrowser.WebBrowserSite classes. The unmanaged WebBrowser ActiveX control uses the protected CreateWebBrowserSiteBase method to retrieve extensibility interfaces implemented by the WebBrowser.WebBrowserSite class. Override the CreateWebBrowserSiteBase method to return an instance of your own class that inherits from the WebBrowser.WebBrowserSite class. The WebBrowser.WebBrowserSite class provides default implementations of the OLE IDocHostUIHandler. You can provide your own implementation of this interface or implement any other WebBrowser ActiveX control interface in order to customize the behavior of the control.

Thanks. Mustafa

LVL 11

Expert Comment

ID: 17176231
that security warning comes with sp2, correct? how about disabling that check in the system? is that an option?

if you uncheck the checkbox of that security window once, the message will never come for that filetype, correct?
so you could find out the regkey for that info and set it up.

by posting my comment, you can close that window, i did not mean, close it by pressing cancle or the x of that window.
you can send that window the hotkey message for the open button, and that is possible.
you would just have to start another thread which checks all windows for the specific, send that message and stop the thread.
thats all.


Author Comment

ID: 17181704
Yes that security warning. Changing the registry key is possible but it affects the whole system (all of the iexplore windows) which is not acceptable. MSDN says it is possible to disable this warning for a specific instance of WebBrowser which I am trying to do.
LVL 11

Expert Comment

ID: 17184336
why dont you modify that key during document loading and restore the old value after loading is finished?

Author Comment

ID: 17192662
Ony a few users has a right to change registry settings most of the users cannot do anything
LVL 11

Accepted Solution

vo1d earned 2000 total points
ID: 17195615
if you cant find a solution for your security problem, take a look at this artikel on how to embed word in your app.
LVL 11

Expert Comment

ID: 17195634
and one more comment, it depends of a setupped regkey, if word, excel, pp will start in your browser or not.
that key could be changed in explorer at the fileoptions. so you would not realy now, if your document will start in your browser or not.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question