Home All Groups Group Topic Archive Search About

How can I let the internet explorer start to navigate in the same windwo?

Author
9 Apr 2005 5:27 AM
husamal_ahmadi
Hi everyBody:

I have this question which really drive me cruzy,
By using VB.Net:

How can I let the internet explorer navigate in the same window either
by using win32 API or by using Microsoft Internet Control refreance to
my project ?

some body toled me to use ShellExcute Function in API but I tried it
and it did not work and some body give me this code :

Option Explicit
Private MyExplorer As InternetExplorer

Private Sub Command1_Click()
  FirstExplorer.Navigate "www.google.com"
End Sub

Public Function FirstExplorer() As InternetExplorer
' REFERENCE Microsoft Internet Controls for:
Dim SW As ShellWindows
Dim IE As InternetExplorer

  If MyExplorer Is Nothing Then

    Set SW = New ShellWindows
    For Each IE In SW
        If TypeName(IE.Document) = "HTMLDocument" Then
          Set MyExplorer = IE
          Exit For
        End If
    Next

    If MyExplorer Is Nothing Then
      ' If there is no Explorer open, then what?
      Set MyExplorer = New InternetExplorer
    End If
  End If

  Set FirstExplorer = MyExplorer

End Function

and alos it did not work with me, and also I used the send function as
follwoing:

Sendmessage(hwnd,WM_SETTEXT,0,"http;//www.yahoo.com/" )

and I foucs that this message set the address bar of the internet
explorer to the url but it did not start to navigate .

So finally Any hlep will be appreciate to solve this problem

Regard's

Husam

Author
9 Apr 2005 7:00 AM
Cor Ligthert
Husamal,

You mean simple this

\\\Needs a form with a button
Private Sub Form7_Load(ByVal sender As System.Object, _
     ByVal e As System.EventArgs) Handles MyBase.Load
        Dim p As New Process
        Dim pi As New ProcessStartInfo
        pi.FileName = "http://www.Google.com"
        p.StartInfo = pi
        p.Start()
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
        Dim p As New Process
        Dim pi As New ProcessStartInfo
        pi.FileName = "http://msdn.microsoft.com"
        p.StartInfo = pi
        p.Start()
    End Sub
///
I hope this helps,

Cor
Author
9 Apr 2005 12:17 PM
Herfried K. Wagner [MVP]
Show quote Hide quote
"Cor Ligthert" <notmyfirstn***@planet.nl> schrieb:
> \\\Needs a form with a button
> Private Sub Form7_Load(ByVal sender As System.Object, _
>     ByVal e As System.EventArgs) Handles MyBase.Load
>        Dim p As New Process
>        Dim pi As New ProcessStartInfo
>        pi.FileName = "http://www.Google.com"
>        p.StartInfo = pi
>        p.Start()
>    End Sub
>    Private Sub Button1_Click(ByVal sender As System.Object, _
>    ByVal e As System.EventArgs) Handles Button1.Click
>        Dim p As New Process
>        Dim pi As New ProcessStartInfo
>        pi.FileName = "http://msdn.microsoft.com"
>        p.StartInfo = pi
>        p.Start()
>    End Sub
> ///

This will only work if Internet Explorer is configured to reuse existing
windows.  Otherwise a new window will be opened.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
9 Apr 2005 2:23 PM
Crouchie1998
I agree with Herfried on that one, Cor

Crouchie1998
BA (HONS) MCP MCSE
Author
9 Apr 2005 2:43 PM
Cor Ligthert
Crouchie,

Did I not, however when it is, than it works as asked.

:-)

Cor
Author
9 Apr 2005 3:12 PM
Cor Ligthert
Crouchie,

However that is the default setting

When it is in another way and want it in the same window than you are
overiding user preferences. What is not right in my opinion.

When it has to be in a new window, it is easily to do, see for that the
answer in this message

http://groups-beta.google.com/group/microsoft.public.dotnet.languages.vb/msg/14b84f389d055d2b

Cor
Author
9 Apr 2005 3:04 PM
Herfried K. Wagner [MVP]
<husamal_ahm***@yahoo.com> schrieb:
Show quoteHide quote
> How can I let the internet explorer navigate in the same window either
> by using win32 API or by using Microsoft Internet Control refreance to
> my project ?
>
> some body toled me to use ShellExcute Function in API but I tried it
> and it did not work and some body give me this code :
>
> Option Explicit
> Private MyExplorer As InternetExplorer
>
> Private Sub Command1_Click()
>  FirstExplorer.Navigate "www.google.com"
> End Sub
>
> Public Function FirstExplorer() As InternetExplorer
> ' REFERENCE Microsoft Internet Controls for:
> Dim SW As ShellWindows
> Dim IE As InternetExplorer
>
>  If MyExplorer Is Nothing Then
>
>    Set SW = New ShellWindows
>    For Each IE In SW
>        If TypeName(IE.Document) = "HTMLDocument" Then
>          Set MyExplorer = IE
>          Exit For
>        End If
>    Next
>
>    If MyExplorer Is Nothing Then
>      ' If there is no Explorer open, then what?
>      Set MyExplorer = New InternetExplorer
>    End If
>  End If
>
>  Set FirstExplorer = MyExplorer
>
> End Function

Add a reference to "Microsoft WebBrowser Control", then use this code
(tested on Windows XP SP2, IE6 SP2):

\\\
Imports SHDocVw
..
..
..
Private MyExplorer As InternetExplorer

Private Sub Form1_Load( _
    ByVal sender As Object, _
    ByVal e As EventArgs _
) Handles MyBase.Load
    FirstExplorer.Navigate("http://www.google.com/")
End Sub

Public Function FirstExplorer() As InternetExplorer
    ' REFERENCE Microsoft Internet Controls for:
    Dim SW As ShellWindows
    Dim IE As InternetExplorer
    If MyExplorer Is Nothing Then
        SW = New ShellWindows
        For Each IE In SW
            If TypeName(IE.Document) = "HTMLDocument" Then
                MyExplorer = IE
                Exit For
            End If
        Next IE
        If MyExplorer Is Nothing Then

            ' Window not yet opened, open new window.
            MyExplorer = New InternetExplorer
            MyExplorer.Visible = True
        End If
    End If
    FirstExplorer = MyExplorer
End Function

Private Sub Button1_Click( _
    ByVal sender As Object, _
    ByVal e As EventArgs _
) Handles Button1.Click
    FirstExplorer.Navigate("http://www.activevb.de/")
End Sub
///

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
9 Apr 2005 3:19 PM
Cor Ligthert
Herfried,

Nice

:-)

Cor