How to handle embedded flash active x control script errors? - c#

I have a winForm panel that has a flash ative x control embedded in it. This works pretty well.
I load the form, add the flash control to the form, then load the .swf file that I wish to play. However, I have a few issues. There is a button in the swf file that is loaded that is marked with an 'x' to denot that it should close the flash plugin.
When this button is clicked it pops an internet explorer window and then shows an error dialog box that says: "Internet Explorer cannot download . Unspecified error"
There is also a 'Continue' button in the flash movie that shows when the movie is over, and it produces the same behavior when the button is clicked.
For this project we are trying to aviod the usage of the WebBrowser control to host the flash video.
Does anyone have any solutions that would allow the application to handle a call that opens a new internet explorer window?
EDIT: I have found more details as to what specifically the issue is. The flash file (.swf) has an embedded call to IE:
javascript:window.close()
This particular call is causing the IE window to pop and then fail. We do not have the ability to change the flash file, is there anyway to handle this call from the windows form and stop it from happening?

Did you steal this SWF?
But to answer you change your embed code.
attributes.allowscriptaccess = "never"

Related

WinAPI Explorer dialog auto select file

For the purposes of my course work, I need to implement an auto-confirmation of the file selection by means of WinApi. There is a browser Chrome, in which some actions take place. And when the dialog window opens for uploading a file, it is necessary to make an automatic selection of the file from the specified path. How can this be done by means of WinAPI? P.S. the application is waiting for the dialog window to start, I have managed to implement this. I found child windows via Window SPY, but when I try to send a message to them by descriptor nothing happens (I tried the class name "Search Box" and the child ones). SendMessage(searchBox,WM_SETTEXT,0,"text");//Not work

VS2012 C# - vshost32 has stopped working

I have a windows form application which is basically a PDF viewer. I used the Adobe PDF Viewer COM component for this project.
The program works but I'm having an issue when I click the close button on the top right of the form after I open a pdf file. When I click the close button, VS does not exit the 'run'-mode and I have to manually click the 'stop' button on VS. And when I press the stop button, a window pops saying "vshost32 has stopped working".
However, this does not happen when I run the application and close it without opening a pdf file.
Any idea why this happens?
You may have manually release the COM object by using Marshal. See this link: http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.releasecomobject.aspx
The vshost32.exe is related to designer-simulation tasks in window forms, so try creating a new project then improt your classes from the old one.

close an open tab in browser from C#

is there any way to close a tab on CHROME, Firefox and IE from C#? I believe that I can accomplish this via JavaScript but I do not know how to call a JS from my C# application. By way of background, my app opens a browser, interacts with the caller then I need to close the open tab.
You probably won't be too successful trying to close a specific tab in the opened browser. You could try to call Process.CloseMainWindow on the launched process, but this may get tricky and potentially close other tabs.
You may want to consider creating a new window (WPF) or form (WinForms) in your app and use the embedded browser control.
If the page you're opening is an asp.net you that you can code... In the method which you want to close the tab, use:
Response.Write("<script type=\"text/javascript\">window.close();</script>");
Otherwise, I can't think of a way either.

Disable prompts in Windows Forms Webbrowser

I have a C# application which uses a System.Windows.Forms.WebBrowser.
The problem is: i'd like the user to navigate smoothly in my application, without prompts, without javascript windows popping up, without security prompts. Even if this requires some contents to be unavailable.
I just want to have one window (always one window, if a receive a new window event, i redirect it to the single window).
How can i do this?
I tried to use this.browser.ScriptErrorsSuppressed = true but i doesnt seem to work.
For example, if i test it on a browser page which performs text validation, i still receive a popup window saying that my text is invalid.
Thank you!
I've found a solution somewhere else, since it wasn't available here.
Here it is: http://www.codeproject.com/Articles/31163/Suppressing-Hosted-WebBrowser-Control-Dialogs
Basically, you have to hook the WM_INITDIALOG message.
It works wonders here.

How do i close all open windows from my C# program?

Hi i have a windows application where i show a webbrowser, i have a button that removes the browser (its a preview) and goes to another "view" in my application (another tab). My problem is that my users are getting advanced, they build HTML with links (and its ok) but the links may spawn new browser windows (IExplorer), and my button needs to close these windows, but how?
I have made some code to traverse all eht windows that ends with "Windows Internet Explorer", ahd it all seems to work - but how do i close them? I am trying to do it like this:
SendMessage((int)hWnd, WM_SYSCOMMAND, SC_CLOSE, 0);
It seems to work, but the browser pops up a dialog asking me if i want to close the tab of all the tabs...how to work around/solve this?
Cheers,
walking over all top level iE windows and closing them is a bad idea, unless you are guaranteed users can't launch ie and browse the Internet on their own. Otherwise, you might actually lose user data (say an email or a blog post the user has been working on in the last half an hour)
You can't easily work around that dialog without modifying the per-user IE settings. Your other option is to look for that dialog and click the yes button, but that would be fragile and is not guaranteed to continue working if the user upgrades to IE9.
You could potentially prevent opening links in new window by listening to BeforeNavigate event and allowing only navigations that are guaranteed to happen in your control. However, there are scenarios where IE might still decide to open new window.

Categories