List Info

Thread: AxWebBrowser in a .Net form and ShowDialog




AxWebBrowser in a .Net form and ShowDialog
user name
2006-12-20 16:57:18
Hi folks

I have the following scenario -

A windows form hosting the AxWebBrowser - I want to be able
to show this
form modaly, allow the user to do some stuff with the url
provided to the
browser control and then dismiss it, returning control to
the parent dialog.

Ideally I'd like to do this using the ShowDialog() method of
the browser
host form and when it is dismisssed maintain the instance
and simply re-
call ShowDialog  e.g.

private BrowserHostForm myForm;

private void button1_Click(object sender, System.EventArgs
e)
{
    if(myForm == null)
    {
        myForm = new BrowserHostForm();
        bfrm.Url = "www.google.com";
    }
    bfrm.ShowDialog(this);
}

In the BrowserHostForm I re-define ShowDialog as follows:

public new DialogResult ShowDialog(IWin32Window parent)
{
    object ms = Type.Missing;
    axWebBrowser1.Navigate(this.Url, ref ms, ref ms, ref ms,
ref ms);
    return base.ShowDialog(parent);
}

The problem arises when I attempt to the button click event
is called the
second time - the Navigate call to the AxWebBrowser always
fails with a COM
excpeption with the message "The requested resource is
in use."

I can use the Show method of the host form with no problems
hiding and re-
showing, but I really need a modal dialog for this
application.

Does anybody have any ideas why the second call would be
failing?  If I
trap the VisibleChanged event of the host form and make the
call to
Navigate after the ShowDialog call, then it succeeds, but
the browser
control displays outside of its host site and is basically
unusable :(

Any help greatly appreciated.

cheers
merv
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )