Welcome Guest Search | Active Topics | Sign In | Register

Cannot Hide and ShowDialog with WebBrowser on a WinForm Options
David Robinson
Posted: Monday, April 13, 2015 12:25:54 PM
Rank: Advanced Member
Groups: Member

Joined: 4/6/2015
Posts: 33
We would like to run WebBrowser on a Windows Form which we can show modally (ShowDialog) and then Hide and later ShowDialog on it again.

This saves the time of having to reload the Windows Form each time.

However, after we Hide the form and go to redisplay it, we get an error that the WebView has been destroyed.
eo_support
Posted: Thursday, April 16, 2015 2:43:21 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,072
Hi,

Please set the UnloadDelay property of the WebView object inside your modal form to a large value. By default when the dialog close, the Form window is destroyed. When the Form window is destroyed, all child windows are destroyed as well, and this would include the browser window except EO.WebBrowser would try to keep alive for a short time as specified by UnloadDelay. So increasing this property will keep the browser window even if the parent form window is destroyed.

Thanks!
David Robinson
Posted: Friday, April 17, 2015 2:29:12 PM
Rank: Advanced Member
Groups: Member

Joined: 4/6/2015
Posts: 33
Did not work. Do I need to do something to detach the WebView from the form? I tried setting WebControl1.WebView to Null and reattaching it, but it did not help, even with UnloadDisplay of 100000.
eo_support
Posted: Friday, April 17, 2015 2:35:15 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,072
Hi,

We tested the following code and it works fine:

Code: C#
TestForm m_Form;

void ShowTestForm()
{
    if (m_Form == null)
        m_Form = new TestForm();
    m_Form.ShowDialog();
}


Here TestForm is a Form with a WebControl and a WebView in it. Setting UnloadDelay to that WebView to a large value would keep the WebView in memory instead of being destroyed when the parent form is destroyed.

Alternatively, you can try to call "Hide" instead of "Close" when your modal form closes. This will keep the form itself alive. The root of the problem here is the parent form is destroyed but you want to keep the WebView inside it alive.

If none of the above resolve the problem for you, please try to isolate the problem into a test project and send us the test project. See here for instructions:

http://www.essentialobjects.com/forum/test_project.aspx

Thanks!
David Robinson
Posted: Thursday, May 21, 2015 6:36:03 PM
Rank: Advanced Member
Groups: Member

Joined: 4/6/2015
Posts: 33
I submitted a test program some time ago. Any response?
eo_support
Posted: Friday, May 22, 2015 11:27:55 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,072
Hi,

The workaround for this is to remove the Me.Hide calls in your code. EO.WebBrowser is optimized for parent window being destroyed, but it seems to have problem with parent window being simply invisible. When the parent window is being destroyed, EO.WebBrowser will not be destroyed immediately, instead it will stay in memory for a period of time (specified by UnloadDelay), and if it is reactivated within that period, it can position itself on screen very fast. So if the only contents in your form is the WebView, then allowing the window to close and destroy will not introduce significant performance penalty.

We do understand ideally your case should work too. As explained in the reply to your other post, we are in the process of updating our code base to Chrome 41, so once that is done we will revisit this as soon as possible.

Thanks!
David Robinson
Posted: Monday, June 8, 2015 4:38:44 PM
Rank: Advanced Member
Groups: Member

Joined: 4/6/2015
Posts: 33
EO.Total_2015.1.53.2.msi seems to have fixed this problem.
eo_support
Posted: Tuesday, June 9, 2015 10:10:08 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,072
Thanks for the update. We are working on the other error that you reported and will let you know as soon as we find something on that one.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.