|
Rank: Member Groups: Member
Joined: 9/27/2014 Posts: 15
|
Support Hi! I have handled the event of newwindow the webview as follows and works correctly, but the site of my project often makes the dialogs with "ok" or "cancel" and these windows are opened in the event of the new window. This returns the result that when I click on the button "ok" of the dialog box, the new window has the effect but then stays open with the empty background and I have to close it manually. How can I handle simultaneously and correctly even the event of the dialog box and newwindow? My code for newwindows:
Code: Visual Basic.NET
Private Sub webview1_NewWindow(ByVal sender As Object, ByVal e As EO.WebBrowser.NewWindowEventArgs) Handles WebView1.NewWindow
e.Accepted = True
Dim WebBrowerOnPopup = New EO.WebBrowser.WinForm.WebControl
Dim popupForm As New System.Windows.Forms.Form
popupForm.ClientSize = New System.Drawing.Size(Convert.ToInt32(e.Width), Convert.ToInt32(e.Height))
popupForm.Controls.Add(WebBrowerOnPopup)
WebBrowerOnPopup.Dock = DockStyle.Fill
WebBrowerOnPopup.WebView = e.WebView
popupForm.Show()
AddHandler popupForm.FormClosed, AddressOf Form_Closed
End Sub
And my code for additional reopening newwindow without waiting (example found on the forum):
Code: Visual Basic.NET
Private Sub Form_Closed(ByVal sender As Object, ByVal e As EventArgs)
popupForm = _
CType(sender, System.Windows.Forms.Form)
Dim webBrowserOnPopup As EO.WebBrowser.WinForm.WebControl = _
CType(popupForm.Controls.Item(0), EO.WebBrowser.WinForm.WebControl)
'Call Destroy on the popup WebView
webBrowserOnPopup.WebView.Destroy()
End Sub
Thanks you!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
I am not sure whether I understand your question correctly. Is below is the scenario that you have?
1. When NewWindow event is fired, you create a new PopupForm that hosts a web page; 2. The web page has an "OK" or "Cancel" button that will call window.close that is meant to close the popup; 3. When user click the button, the web page inside PopupForm disappears, but the form itself still stays on the screen;
If this is the case, you will need to handle the new WebView's Closed event, then close the PopupForm inside the WebView's Closed event handler. What you did is the other way around. You try to close the WebView when the Form is closed. This is not necessary because the WebView will be automatically destroyed when the parent Form is destroyed. However the reverse direction is not true --- the Form will NOT be destroyed even if the WebView is destroyed. This is because the WebView is a child control inside the Form. So when the parent is destroyed, all children are destroyed. However destroying a children does not automatically destroy the parent and other siblings. This is why closing the WebView will not automatically close the Form. However you can make this happen by handling the WebView's Closed event and then close the Form inside the event handler.
Hope this helps. Please feel free to let us know if you still have any more questions.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 9/27/2014 Posts: 15
|
Hi, I will try to explain more clearly my problem: From the following link, I took the example to successfully open a new window, where a user asked for your help, and with your solution, proposed in that case, there is no need to wait 10 seconds before re-opening the new window.: >>LINK<<This code works very well with many sites and the window opens regularly when the event newwindow is called from any site .. But when I try to open my own site, that only on occasion brings up a dialog box, this dialog box is opened through the same event newwindow. In this specific case, when I choose the "ok" or "cancel", the command is sent, but the popupForm remains open with the white background. I would like to continue to use the code I listed in the first message, however, manage the dialog box so that after my choice, this is closed as happens regularly opening the dialog box with a normal browser. The problem is only with dialog box and not with the new open windows containing new pages. How can I change the code to make it work in both cases? I hope to be able to explain. Thanks you
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
I still do not quite understand your question. If your goal is to close your own PopupForm, why can't you just call Close on that form to close it? What does that has to do with EO.WebBrowser?
Thanks
|
|
Rank: Member Groups: Member
Joined: 9/27/2014 Posts: 15
|
Hi Support, Surely the solution will be trivial, but I'm stuck on this problem. How can I close the dialog box after confirmation? The dialog box is generated from the site and is in control webview of newwindow popupform. Then the dialog box does not always appear, and in some cases the new window is a simple new page, and this is closed by me manually, as I can intercept that it is a dialog box, and after confirmation to automatically close the popupForm? I have tried in various ways to automatically close the popupForm after confirmation of the dialog box, but without success. For example, the following code to a list ErrorBox that opens in a new window, and I want it closed after confirmation:
Code: HTML/ASPX
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head>
<link rel="stylesheet" type="text/css" href="MsgBoxStyleSheet.css" title="style">
<title>Errore</title></head>
<body ms_positioning="GridLayout" class="ErrorBox">
<form id="Form1" method="post">
<table id="Table1" width="100%" height="100%" cellspacing="0" cellpadding="5" border="0">
<tbody><tr>
<td valign="top" width="60" align="center"><span style="title='Error';width:48px;height:48px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='exclamation.png', sizingMethod='scale');"></span></td>
<td valign="top" width="360"><script>document.writeln(window.dialogArguments[1]);</script>Attention, are some errors in the data:<br><br>* LOGIN Field can not be empty<br>* PASSWORD Field can not be empty<br>
</td>
</tr>
<tr>
<td colspan="2" valign="middle" align="center">
<input id="AlertButton" onclick="parent.window.returnValue = true; parent.window.close();" type="button" name="AlertButton" value=" OK ">
</td>
</tr>
</tbody></table>
</form>
<script>
document.title=window.dialogArguments[2];
var img = Form1.icona
var strNewHTML = "<span style=\"title='" + window.dialogArguments[2] + "';width:48px;height:48px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'" + window.dialogArguments[3] + "\', sizingMethod='scale');\"></span>"
img.outerHTML = strNewHTML
</script>
</body></html>
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
I believe our first reply has already answered your question: You need to handle the WebView's Closed event and then close your form inside the event handler.
Thanks
|
|