How to launch webbrowser from VB6? 
Author Message
 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  
 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  
 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  
 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  
 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  
 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  
 
 [ 6 post ] 

 Relevant Pages 

1. How to launch webbrowser from VB6?

2. How to launch webbrowser from VB6?

3. WebBrowser without WebBrowser Control in VB6 ?

4. Launch from webbrowser to email...

5. Launching applications with webbrowser control

6. How to launch Browser App from WebBrowser control?

7. newbie: launch default webbrowser?

8. launching a batch file from VB6 app

9. Launch an app modally from VB6

10. Launch a Web browser from VB6

11. VB6 ActiveX launches IE

12. InternetAutodial Function--How to Launch from VB6?

 

 
Powered by phpBB® Forum Software