Passing in a file to a browser...

  • Thread starter Thread starter Robert
  • Start date Start date
R

Robert

I am creating a small help browser. It is pretty much finished except I
cannot find how to pass a file to it (i.e. browser.exe index.html, or any
html file, and the html file opens in the browser) from the command line.

Pointers would help. : )

Bob
 
Hi Robert,

Strange Herfried did not answer this one because it looks to me that you are
only asking this one

\\\
Dim psi As New ProcessStartInfo
psi.FileName = "http://www.bla.foo"
psi.UseShellExecute = True
Process.Start(psi)
///

When you are longer on this newsgroup you recognise the typical Herfried
code.

However maybe I am wrong?

Cor
 
Cor Ligthert said:
Hi Robert,

Strange Herfried did not answer this one because it looks to me that you are
only asking this one

\\\
Dim psi As New ProcessStartInfo
psi.FileName = "http://www.bla.foo"
psi.UseShellExecute = True
Process.Start(psi)
///

When you are longer on this newsgroup you recognise the typical Herfried
code.

However maybe I am wrong?

Cor

Thanks. That hardcodes the filename? I was looking to be able to launch any
HTML file from the command line. But it gives me a start to work from...
 
Robert,
Try:

Public Module MainModule
Public Sub Main(ByVal args() As String)End Sub
End Module

Hope this helps
Jay
 
Maybe I am doing something wrong so I am going to be more verbose. I need to
created a minimal browser to view some help files that are in HTML. I
created a standard Windows form and put the AxWebBrowser control on it as
well as a toolbar with "back", "forward", and "exit". I can drag and drop an
HTML file on the running application and it renders the page and I can move
back and forth with my nav buttons. I cannot (even using the snippet you
gave) pass an HTML page via the command line and have the AxWebBrowser
control display it.

Without going in to much detail. We have a 3rd party application that
currently opens IE to view its help files (which opens holes we do not want
to deal with) so I intend to "replace" IE with my little help browser and
make all the big wigs happy. And learn VB.NET is the process! : )
 
Hi Robert,

This seems to me a total different approach, you did something as this

Open a new windows application project

In the toolbox rightclick and select add/Remove items

In the customize toolbox select Com and in that Microsoft Webbrowser

When that is in the toolbox drag it to your form
Drag also a button to your form.

Then this code and you have a mini Webbrowser.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Me.AxWebBrowser1.Navigate2("www.google.com")
End Sub

While that www.google.com can be a textbox of course or your html file.

A very complete sample is here.

webbrowser
http://support.microsoft.com/?kbid=311303

And what more documentation.
mshtml
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/hosting/hosting.asp
 
Cor Ligthert said:
Hi Robert,

This seems to me a total different approach, you did something as this

Open a new windows application project

In the toolbox rightclick and select add/Remove items

In the customize toolbox select Com and in that Microsoft Webbrowser

When that is in the toolbox drag it to your form
Drag also a button to your form.

Then this code and you have a mini Webbrowser.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Me.AxWebBrowser1.Navigate2("www.google.com")
End Sub

While that www.google.com can be a textbox of course or your html file.

A very complete sample is here.

webbrowser
http://support.microsoft.com/?kbid=311303

And what more documentation.
mshtml
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/hosting/hosting.asp
Right. Like I said I have it almost completed. It does not (and the examples
above do not) allow me to pass an HTML file from the command line. I can
drop an HTML file on the running app and that works. I would also not like
to have to hard code a path. I am new to VB.NET so maybe I am not focusing
my thoughts correctly. : )
 
Robert,
You did notice that my sample allowed you to pass a file from the command
line?

There are a number of methods to pass parameters to your program, I prefer
the Main(args) method

Public Sub Main(ByVal args() As String)
End Sub

If you have an embeded browser you could do something like:

Public Class MainForm
Inherits Form

Public Shared Sub Main(ByVal args() As String)
Dim mainForm As New MainForm
mainForm.AxWebBrowser1.Navigate2(args(0))
Application.Run(mainForm)
End Sub

End Class

Alternatively you can use the VB.NET Command() function to load the browser:

Still another method would be to use either System.Environment.CommandLine
or System.Environment.GetCommandLineArgs().

I would use Environment.CommandLine if I wanted to parse the complete
command line myself, otherwise I would use Environment.GetCommandLineArgs()
which seperates the command line into individual string tokens... However I
mostly use the Sub Main(args() As String) method.

Hope this helps
Jay
 
Jay B. Harlow said:
Robert,
You did notice that my sample allowed you to pass a file from the command
line?

There are a number of methods to pass parameters to your program, I prefer
the Main(args) method

Public Sub Main(ByVal args() As String)
End Sub

If you have an embeded browser you could do something like:

Public Class MainForm
Inherits Form

Public Shared Sub Main(ByVal args() As String)
Dim mainForm As New MainForm
mainForm.AxWebBrowser1.Navigate2(args(0))
Application.Run(mainForm)
End Sub

End Class

Alternatively you can use the VB.NET Command() function to load the browser:
Still another method would be to use either System.Environment.CommandLine
or System.Environment.GetCommandLineArgs().

I would use Environment.CommandLine if I wanted to parse the complete
command line myself, otherwise I would use Environment.GetCommandLineArgs()
which seperates the command line into individual string tokens... However I
mostly use the Sub Main(args() As String) method.

Hope this helps
Jay




http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/hosting/hosting.asp
Thanks!!!
 
Back
Top