List Info

Thread: AxWebBrowser in a .Net form and ShowDialog




AxWebBrowser in a .Net form and ShowDialog
user name
2006-12-20 22:01:02
I never was able to work out what the problem was with
hiding the browser
control or its container.
With maximising it, the problem is something like the
control assigns 100%
of its resources to doing nothing, the events are never
fired and the page
never loads.

Using a true dialog may be pushing the browser control a bit
far.
The cleanest solution that I can think of is to
programatically create the
browser control when the dialog is shown, and of course
dispose it when the
dialog is hidden.
It's possible that you'll need to tie into browser events
and prevent hiding
the dialog until the browser fires DocumentComplete.

trial, error, lots more testing ...
ps

----- Original Message -----
From: "Mervyn Russell" <mervynrussellHOTMAIL.COM>
To: <DOTNET-WINFORMSDISCUSS.DEVELOP.COM>
Sent: Thursday, December 21, 2006 8:36 AM
Subject: Re: [DOTNET-WINFORMS] AxWebBrowser in a .Net form
and ShowDialog


> Hi Peter
>
> Yeah, default form behaviour is to simply hide the form
when it is closed
> if
> it has been called using ShowDialog.  What exactly is
it about hiding the
> form that screws up the browser control?  And is there
any way around it?
>
> I've got a workaround at the moment which involves
calling the host form
> non-modally (using Form.Show) inside a holder form
which is called
> modally,
> but this is giving me problems in other areas of my
application.  Ideally
> I'd like a 'clean' solution that deals directly with
the problem of the
> browser control being called inside a modal dialog
which is re-used.
>
> I've been searching about various forums for a few days
and I've seen the
> many quirks and snafus associated with the browser
control, but I haven't
> come across any which specifically mention this
situation.  Is what I'm
> trying to do a reasonble use of the control??
>
>
>>From: Peter Suter <petersuterOZEMAIL.COM.AU>
>>Reply-To: Discussion forum for developers using
Windows Forms to build
>>apps
>>              and controls <DOTNET-WINFORMSDISCUSS.DEVELOP.COM>
>>To: DOTNET-WINFORMSDISCUSS.DEVELOP.COM
>>Subject: Re: [DOTNET-WINFORMS] AxWebBrowser in a
.Net form and ShowDialog
>>Date: Thu, 21 Dec 2006 08:10:34 +1100
>>
>>There are (more than) a couple of things that
AxWebBrowser has a problem
>>with
>>- When the hosting form/control is maximised
>>- When the hosting form/control is hidden
>>
>>Doesn't dialog behaviour hide the form?
>>ps
>>
>>----- Original Message -----
>>From: "Mervyn Russell"
<mervynrussellHOTMAIL.COM>
>>To: <DOTNET-WINFORMSDISCUSS.DEVELOP.COM>
>>Sent: Thursday, December 21, 2006 3:57 AM
>>Subject: [DOTNET-WINFORMS] AxWebBrowser in a .Net
form and ShowDialog
>>
>>
>>>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
>>>
>
>
____________________________________________________________
_____
> Think you're a film buff? Play the Movie Mogul quiz and
win fantastic
> prizes!  http://www.msnmoviemogul
.com
>
[1]

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