How to launch webbrowser from VB6?
Author |
Message |
E.J. #1 / 8
|
 How to launch webbrowser from VB6?
How do I launch my webbrowser from VB6? In VB3 the following function worked just fine, but not under VB6. Declare Function ShellExecute Lib "shell.dll" (ByVal hWnd As Integer, ByVal Options As Long, ByVal FileName As String, ByVal Params As Long, ByVal DefaultDir As String, ByVal ShowCmd As Integer) As Integer Sub ConnectToWebPage(WebPage As String) Dim rtn As Integer, MyDir As String MyDir = CurDir$ rtn = ShellExecute(Screen.ActiveForm.hWnd, 0, WebPage, 0, MyDir, SW_SHOWMAXIMIZED) If Not rtn > 32 Then Msg = "Connection failed." MsgBox (Msg), 16, "nO Connection" End If End Sub -- Eric J. van Dorp Van Dorp Educatieve Programmatuur
Postbox 268 2990 AG Barendrecht The Netherlands
|
Sat, 22 Dec 2001 03:00:00 GMT |
|
 |
Clive.Allw.. #2 / 8
|
 How to launch webbrowser from VB6?
Try this: rc = ComWeb_LaunchWWW(Me.hwnd, "microsoft.com") 'might need www.microsoft.com Option Explicit 'Example call: rc = ComWeb_LaunchWWW(Me.hwnd, "bcassessment.icw.gov.bc.ca") 'Common bas module code follows: Const SW_SHOWNORMAL = 1 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 Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As String, ByVal lpResult As String) As Long Public Function ComWeb_LaunchWWW(lYourHwnd As Long, sWWWURL As String) As Boolean 'This function launches the users default web browser to the specified web site 'True is returned upon success, False is returned otherwise Dim sFileName As String, sDummy As String Dim sBrowserExec As String * 255 Dim lRetVal As Long Dim iFileNumber As Integer On Error Resume Next sBrowserExec = Space$(255) sFileName = "C:\temphtm.htm" iFileNumber = FreeFile() 'create a dummy html file so we can determine the default browser location Open sFileName For Output As #iFileNumber Write #iFileNumber, "<HTML> <\HTML>" Close #iFileNumber 'this function will return the browser path lRetVal = FindExecutable(sFileName, sDummy, sBrowserExec) If lRetVal <= 32 Then ComWeb_LaunchWWW = False Exit Function End If 'now tell the browser to open the web site lRetVal = ShellExecute(lYourHwnd, "open", sBrowserExec, sWWWURL, sDummy, SW_SHOWNORMAL) If lRetVal <= 32 Then ComWeb_LaunchWWW = False Exit Function End If 'get rid of the temp html file Kill sFileName ComWeb_LaunchWWW = True Err.Clear End Function This code came originally from VB Tips I think??? Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't.
|
Sat, 22 Dec 2001 03:00:00 GMT |
|
 |
crazyALE #3 / 8
|
 How to launch webbrowser from VB6?
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 Const SW_SHOWNORMAL = 1 Private Sub Form_Load() ShellExecute Me.hwnd, vbNullString, "xxx.com, vbNullString, "C:\", SW_SHOWNORMAL End Sub best regards Alex -- Dim Life as Boolean Life = True
http://www.crazyALEX.notrix.de ich wnsche noch nen bug-freien Tag! i'll wish you a bug-free day!
Quote: >How do I launch my webbrowser from VB6? In VB3 the following function worked >just fine, but not under VB6. >Declare Function ShellExecute Lib "shell.dll" (ByVal hWnd As Integer, ByVal >Options As Long, ByVal FileName As String, ByVal Params As Long, ByVal >DefaultDir As String, ByVal ShowCmd As Integer) As Integer >Sub ConnectToWebPage(WebPage As String) > Dim rtn As Integer, MyDir As String > MyDir = CurDir$ > rtn = ShellExecute(Screen.ActiveForm.hWnd, 0, WebPage, 0, MyDir, >SW_SHOWMAXIMIZED) > If Not rtn > 32 Then > Msg = "Connection failed." > MsgBox (Msg), 16, "nO Connection" > End If >End Sub >-- >Eric J. van Dorp >Van Dorp Educatieve Programmatuur
>Postbox 268 >2990 AG Barendrecht >The Netherlands
|
Sat, 22 Dec 2001 03:00:00 GMT |
|
 |
Howard Henry Schlunde #4 / 8
|
 How to launch webbrowser from VB6?
Awesome! How did you find out about those two properties in the browser object? -- Howard Henry 'Gawyn Ballpeen' Schlunder Gawyn Developments; Core developer http://venus.ajusd.org/~hschlund/
Quote: > You should actually use the WebBrowser control to access the Explorer > type interface from VB and retain control over it. Launching other > applications is not always something you should want to do. > There is a lot more control over the browser when you use it from > within VB including your browser.innerTEXT and browser.innerHTML > properties which allow you to analyze exacty what is onscreen and > capture it or automate Web functions and navigation smartly.
|
Sat, 22 Dec 2001 03:00:00 GMT |
|
 |
Harmonious Loboto #5 / 8
|
 How to launch webbrowser from VB6?
You should actually use the WebBrowser control to access the Explorer type interface from VB and retain control over it. Launching other applications is not always something you should want to do. There is a lot more control over the browser when you use it from within VB including your browser.innerTEXT and browser.innerHTML properties which allow you to analyze exacty what is onscreen and capture it or automate Web functions and navigation smartly. Quote:
>Dim RetVal >RetVal = Shell("explorer.exe http://sitetogo.net", 1)
> How do I launch my webbrowser from VB6? In VB3 the following function worked > just fine, but not under VB6. > Declare Function ShellExecute Lib "shell.dll" (ByVal hWnd As Integer, ByVal > Options As Long, ByVal FileName As String, ByVal Params As Long, ByVal > DefaultDir As String, ByVal ShowCmd As Integer) As Integer > Sub ConnectToWebPage(WebPage As String) > Dim rtn As Integer, MyDir As String > MyDir = CurDir$ > rtn = ShellExecute(Screen.ActiveForm.hWnd, 0, WebPage, 0, MyDir, > SW_SHOWMAXIMIZED) > If Not rtn > 32 Then > Msg = "Connection failed." > MsgBox (Msg), 16, "nO Connection" > End If > End Sub > -- > Eric J. van Dorp > Van Dorp Educatieve Programmatuur
> Postbox 268 > 2990 AG Barendrecht > The Netherlands
|
Sun, 23 Dec 2001 03:00:00 GMT |
|
 |
zima #6 / 8
|
 How to launch webbrowser from VB6?
or try this... Shell("start http://nextsite.com", vbNormal) Quote:
> How do I launch my webbrowser from VB6? In VB3 the following function worked > just fine, but not under VB6. > Declare Function ShellExecute Lib "shell.dll" (ByVal hWnd As Integer, ByVal > Options As Long, ByVal FileName As String, ByVal Params As Long, ByVal > DefaultDir As String, ByVal ShowCmd As Integer) As Integer > Sub ConnectToWebPage(WebPage As String) > Dim rtn As Integer, MyDir As String > MyDir = CurDir$ > rtn = ShellExecute(Screen.ActiveForm.hWnd, 0, WebPage, 0, MyDir, > SW_SHOWMAXIMIZED) > If Not rtn > 32 Then > Msg = "Connection failed." > MsgBox (Msg), 16, "nO Connection" > End If > End Sub > -- > Eric J. van Dorp > Van Dorp Educatieve Programmatuur
> Postbox 268 > 2990 AG Barendrecht > The Netherlands
|
Sun, 23 Dec 2001 03:00:00 GMT |
|
 |
Mike Sloa #7 / 8
|
 How to launch webbrowser from VB6?
Alternative approach... Include the Microsoft Internet Controls library in the References of your Project and... Dim MyBrowser As SHDocVw.InternetExplorer Set MyBrowser = New SHDocVw.InternetExplorer MyBrowser.Visible = True MyBrowser.Navigate "http://www.whereyouwanttogo.com
|
Sun, 23 Dec 2001 03:00:00 GMT |
|
 |
LONG #8 / 8
|
 How to launch webbrowser from VB6?
E.J. Very Simply, you need to create and instance of the application, like: dim o as objects set o = createobject("explorer.application") 'Check name in registry That's it, your ready to use the object for whatever! Quote:
>How do I launch my webbrowser from VB6? In VB3 the following function worked >just fine, but not under VB6. >Declare Function ShellExecute Lib "shell.dll" (ByVal hWnd As Integer, ByVal >Options As Long, ByVal FileName As String, ByVal Params As Long, ByVal >DefaultDir As String, ByVal ShowCmd As Integer) As Integer >Sub ConnectToWebPage(WebPage As String) > Dim rtn As Integer, MyDir As String > MyDir = CurDir$ > rtn = ShellExecute(Screen.ActiveForm.hWnd, 0, WebPage, 0, MyDir, >SW_SHOWMAXIMIZED) > If Not rtn > 32 Then > Msg = "Connection failed." > MsgBox (Msg), 16, "nO Connection" > End If >End Sub >-- >Eric J. van Dorp >Van Dorp Educatieve Programmatuur
>Postbox 268 >2990 AG Barendrecht >The Netherlands
|
Sun, 23 Dec 2001 03:00:00 GMT |
|
|
|