Solved

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

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

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now