Click to See Complete Forum and Search --> : How Can I Make It Go To web Page using the same browser ...............
XxEvilxX
Nov 4th, 1999, 06:36 AM
How Can I Make It Go To web Page using the same browser and if there one not open one it well open one?
Compwiz
Nov 4th, 1999, 07:01 AM
Try this.
.bas
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Dim success As Integer
Function ShellToBrowser%(Frm As Form, ByVal URL$, ByVal WindowStyle%)
Dim api%
api% = ShellExecute(Frm.hwnd, "open", URL$, "", App.Path, WindowStyle%)
'Check return value
If api% < 31 Then
'error code - see api help for more info
MsgBox App.Title & " had a problem running your web browser." & _
"You should check that your browser is correctly installed." & _
"(Error" & Format$(api%) & ")", 48, "Browser Unavailable"
ShellToBrowser% = False
ElseIf api% = 32 Then
'no file association
MsgBox App.Title & " could not find a file association for " & _
URL$ & " on your system. You should check that your browser" & _
"is correctly installed and associated with this type of file.", 48, "Browser Unavailable"
ShellToBrowser% = False
Else
'It worked!
ShellToBrowser% = True
End If
End Function
Public Sub LaunchSite(Site As String, frm As Form)
success% = ShellToBrowser(frm, Site, 0)
End Sub
Form Code:
Private Sub Command1_Click()
LaunchSite "http://www.vb-world.net", Me
End Sub
I'm not too sure that this will work, but try it... however I think it does.
------------------
Tom Young, 14 Year Old
tom@e-bizinternet.com
ICQ: 15743470
AIM: TomY10
PERL, JavaScript and VB Programmer
Aaron Young
Nov 4th, 1999, 08:19 AM
Here's a routine I wrote a while back which does just that..
In a Module..
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetNextWindow Lib "user32" Alias "GetWindow" (ByVal hwnd As Long, ByVal wFlag As Long) As Long
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const GW_CHILD = 5
Private Const GW_HWNDNEXT = 2
Private Const WM_SETTEXT = &HC
Private Const WM_KEYDOWN = &H100
Private lEditHwnd As Long
Public Function NavigateIE(ByVal sString As String) As Boolean
Dim lIEWnd As Long
lIEWnd = FindWindowEx(0&, 0&, "IEFrame", vbNullString)
If lIEWnd Then
Call EnumHwnd(lIEWnd)
Call SendMessage(lEditHwnd, WM_SETTEXT, 0&, ByVal sString)
Call SendMessage(lEditHwnd, WM_KEYDOWN, vbKeyReturn, 0&)
Call SetForegroundWindow(lIEWnd)
NavigateIE2 = True
Else
ShellExecute 0, "OPEN", sString, "", "", 1
End If
End Function
Private Sub EnumHwnd(ByVal hwnd As Long)
Dim lChild As Long
Dim sClass As String * 255
lChild = GetWindow(hwnd, GW_CHILD)
Do While lChild
Call GetClassName(lChild, sClass, 255)
If Left(sClass, 4) = "Edit" Then
lEditHwnd = lChild
Exit Do
End If
Call EnumHwnd(lChild)
lChild = GetNextWindow(lChild, GW_HWNDNEXT)
Loop
End Sub
Usage: NavigateIE "URL"
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net
XxEvilxX
Nov 4th, 1999, 08:38 AM
thanx everyone and arron i like yours the best and thanx
Juan Carlos Rey
Nov 4th, 1999, 08:38 AM
If all you want to do is display the page, why don't you just use a WebBrowser?
It's a lot simpler:
WebBrowser1.Navigate (your URL here)
You can even keep it invisible until you need to use it.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.