AxWebBrowser without form

  • Thread starter Thread starter Mantorok
  • Start date Start date
M

Mantorok

Hi

Is there anyway to get a WebBrowser to work without placing it on a form.

I want to be able to instantiate a browser, complete some of the fields and
submit, but whenever I try to navigate I get:

An unhandled exception of type 'InvalidActiveXStateException' occurred in
axinterop.shdocvw.dll

I'm assuming that's because it hasn't got a handle assigned to it, is there
any other method/workaround?

Ideas?

Thanks
Kev
 
Hi,
I'm not sure is this the same problem as the one i had, so maybe this is not
solution for your problem but it wont hurt if you try :)

A handle for AxWebControl is created, not when you create the control but
when it is shown.
The bug here is that when you try to close form which contains AxWebBrowser
control (actually when the GC try to dispose the control) and the control is
not yet shown so it doesn't have handle, it raises exeption similar to the
one you had mentioned.

The solution was to hide the control until you need to show it. So, after:

AxWebBrowser aWB = new AxWebBrowser(); // actually after
InitializeComponent();

somewhere in constructor add:

aWB.Hide();

and:

aWB.Show();

when you need to display it!
 
Back
Top