Solved

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

Posted on 2006-07-24
13
1,084 Views
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.

Thanks,
Mustafa Kok
0
Comment
Question by:muskok
  • 6
  • 3
13 Comments
 
LVL 11

Expert Comment

by:vo1d
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?
0
 
LVL 7

Expert Comment

by:whatsit2002
ID: 17170365
Mustafa,

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.

Thanks.

Jason
0
 
LVL 11

Expert Comment

by:vo1d
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?
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

Author Comment

by:muskok
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


0
 
LVL 11

Expert Comment

by:vo1d
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.



0
 

Author Comment

by:muskok
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.
0
 
LVL 11

Expert Comment

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

Author Comment

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

Accepted Solution

by:
vo1d earned 500 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.
http://www.codeproject.com/dotnet/WordInDotnet.asp
0
 
LVL 11

Expert Comment

by:vo1d
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.
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

777 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