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

H

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
 
C

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
 
H

Herfried K. Wagner [MVP]

Cor Ligthert said:
\\\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.
 
H

Herfried K. Wagner [MVP]

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
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top