I have two forms: form1 is the starting form; form2 is a form with a webBrowser control.
If I navigate the browser control from form2 where the webbrowser resides it works fine.
If I navigate form2’s browser control from form1 my firewall and network monitor tells me that an http request has been issued and then completed but the browser control remains blank.
Any known restrictions or bugs driving a browser control remotely that I may have missed
Thanks GregCost
CODE from form1:
Private Sub form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.Alt Then
Dim form2 As New Form2()
form2.AxWebBrowser1.Navigate("www.microsoft.com")
End If
End Sub

Problems/bug? Navigating Webbrowser control from a remote form
RichBond007
That's why we did the work for you.
With KUMO Editor (www.softmorning.net), you can create DLL objects
with a constructor that will only take your current program axWebBrowser object reference.
This DLL will execute a web macro script that is written a C#.
You will then be able to automate the browser, to catch events, save objects properties,
catch internet explorer pop ups, make screen copies, save files, images, and manipulate
the page document in a way you would never have been able to do with the standard mshtml library.
It will also deal with all the timing issues.
So if you are frustrated with axWebBrowser and mshtml programming, it's time to
have a look on www.softmorning.net
madda
Actually i am not able to even run a form containing the web browser control. Am getting this error
"
An unhandled exception of type 'System.Threading.ThreadStateException' occurred in IEExec.exe
Additional information: Could not instantiate ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' because the current thread is not in a single-threaded apartment.
"
any ideas
Greg Rutherford
One thing I did leave out and now thinking about it, it may be important, is that there are actually two web control browses on form2. It may be an issue – I will test it with only one.
I will give your suggestion a try. I will create a class with a public method to navigate the browser and call it from form1. Could you elaborate a little as to why exposing the control in the way that I have is bad architectually
Last and Interestingly enough I have also encountered a form focus problem with the same two forms.
Same two forms, 1 and 2. Form1 is the starting form and form2 two is loaded (.show) by form1. Form1 then minimizes but sets the focus to form2.
Neither forms have focus I can verify this by using a canFocus and a subsequent .focus statements with console.wrtelines. The code and output from the run is below.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.ShowInTaskbar = True
Me.WindowState = FormWindowState.Minimized
Form2.Show()
Form2.Visible = True
Form2.Enabled = True
Form2.Focus()
Console.WriteLine(Me.CanFocus)
Console.WriteLine(form1.CanFocus)
Console.WriteLine(form1.Focus)
Console.WriteLine(Me.Focus)
End Sub
WindowsApplication1.exe': Loaded 'c:\documents and settings\administrator\my documents\visual studio projects\windowsapplication1\bin\interop.shdocvw.dll', No symbols loaded.
True
True
False
False
The program '[5180] WindowsApplication1.exe' has exited with code 0 (0x0).
CSSMr.Smith
class form2 : Form
{
public void Navigate(string uri)
{
AxWebBrowser1.Navigate(uri)
}
}
this works well for me every time
Doomgrinder
That's why we did the work for you.
With KUMO Editor (www.softmorning.net), you can create DLL objects
with a constructor that will only take your current program axWebBrowser object reference.
This DLL will execute a web macro script that is written a C#.
You will then be able to automate the browser, to catch events, save objects properties,
catch internet explorer pop ups, make screen copies, save files, images, and manipulate
the page document in a way you would never have been able to do with the standard mshtml library.
It will also deal with all the timing issues. You can include C# code in your web macro.
So if you are frustrated with axWebBrowser and mshtml programming, it's time to
have a look on www.softmorning.net
dribar
>>Could you elaborate a little as to why exposing the control in the way that I have is bad architectually
A form , is a class like your control or your other business object, you only expose the necessary things to satistfy your business needs, that's the concept of absraction and encapsulation in OO. thus the parent does not need to know to internal working of your object all they need to care is your object is capable to do you a service
say if I got a Login form, i don't want to expose all the textboxes to the parent, may be i just want to expose the validity of the credential
class Login:Form
{
//
// leave the rest, set the return dialog
// i have a property called IsVaild, now how do i get this, is not a matter
// of concern to the parent
public bool IsValid
{
get { return textname.Text == "ery" && textPass.Text=="myPassword"; }
}
}
//
// now in my parent
using (Login login = new Login())
{
if( login.ShowDialog() == DialogResult.OK)
{
// check the IsValid
if(login.IsValid)
// do something here
else
// do something else
}
}
>>Same two forms, 1 and 2. Form1 is the starting form and form2 two is loaded (.show) by form1. Form1 then minimizes but sets the focus to form2.
If your intention is to show form2 then hide form1, you ming as well use ShowDialog, thus the form2 will receive the focus automatically
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Form2 f = new Form2()
f.ShowDialog()
Finally
f.Dispose()
End Try
End Sub