Results 1 to 8 of 8

Thread: WebBrowser control in VB6 -shdocvw.dll not working in Windows 8

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2008
    Posts
    248

    WebBrowser control in VB6 -shdocvw.dll not working in Windows 8

    I am using WebBrowser control in VB6. when i develop this in a Windows XP machine and when i add Microsoft Internet Controls reference , shdocvw.dll gets added. And my application works fine in XP. If i create the same project in a Windows 8 PC when i add Microsoft Internet Controls reference, ieframe.dll gets added automatically.But if i use shdocvw.dll then the application files to work in Windows 8 PC. Also there is change in procedure in xp and windows 8.In XP it will be WebBrowser2_FileDownload(Cancel As Boolean) and in Windows 8 the procedure will be WebBrowser2_FileDownload(ByVal ActiveDocument As Boolean, Cancel As Boolean).
    I want to use shdocvw.dll in both Windows XP and Windows 8, and it should work properly.Can anyone help me on this?

  2. #2
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: WebBrowser control in VB6 -shdocvw.dll not working in Windows 8

    Try dynamically creating the WebBrowser control (remove the reference to Microsoft Internet Controls first) so you can adjust your code according to the OS:

    Code:
    'In a Form
    
    Option Explicit
    
    Private WithEvents WebBrowser As VBControlExtender
    
    Private IsWinXP As Boolean, IsWin8 As Boolean
    
    Private Sub Form_Activate()
       'Use the object property of VBControlExtender to access other methods of the WebBrowser
        WebBrowser.object.Navigate "http://www.vbforums.com/"
    End Sub
    
    Private Sub Form_Load()
       'Add OS version test here (or better yet, test IE version)
        IsWinXP = True
    
       'Not sure if ProgId's same for Win8
        Set WebBrowser = Controls.Add("Shell.Explorer.2", "WebBrowser1")
        WebBrowser.Visible = True
    End Sub
    
    Private Sub Form_Resize()
        If WindowState <> vbMinimized Then WebBrowser.Move ScaleLeft, ScaleTop, ScaleWidth, ScaleHeight
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        Set WebBrowser = Nothing
        Controls.Remove "WebBrowser1"
    End Sub
    
    Private Sub WebBrowser_ObjectEvent(Info As EventInfo)
        With Info
            Select Case .Name
                Case "StatusTextChange"
                    With .EventParameters
                        Select Case True
                            Case IsWinXP: Caption = .Item("Text")
                            Case IsWin8:  Caption = .Item("Text")
                        End Select
                    End With
    
                Case "FileDownload"
                    With .EventParameters
                        Select Case True
                            Case IsWinXP: WebBrowser2_FileDownload_XP .Item("Cancel")
                            Case IsWin8:  WebBrowser2_FileDownload_8 .Item("ActiveDocument"), .Item("Cancel")
                        End Select
                    End With
    
                Case "Other Events Here"
    
            End Select
        End With
    End Sub
    
    Private Sub WebBrowser2_FileDownload_XP(Cancel As Boolean)
    
    End Sub
    
    Private Sub WebBrowser2_FileDownload_8(ByVal ActiveDocument As Boolean, Cancel As Boolean)
    
    End Sub
    Tested only on XP.

    References:

    How To Dynamically Add Controls to a Form with Visual Basic 6.0

    How to load a control at runtime.

    VBControlExtender Object
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  3. #3
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: WebBrowser control in VB6 -shdocvw.dll not working in Windows 8

    Didn't this change a long, long time ago? Like with IE 6.0 or something?

    I don't see the old signature anymore, and current documentation only shows the current one which works fine on Vista, Windows 7, Windows 8, etc.

    FileDownload Event

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Oct 2008
    Posts
    248

    Re: WebBrowser control in VB6 -shdocvw.dll not working in Windows 8

    Hi dilettante..
    yes i am getting problem in IE 6 . How can i solve this?

  5. #5
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: WebBrowser control in VB6 -shdocvw.dll not working in Windows 8

    Forgot to mention I tested that code with IE v8. IE8 in XP doesn't have the ActiveDocument parameter for the FileDownload event of the WebBrowser object.
    Last edited by Bonnie West; Jun 14th, 2013 at 08:24 AM.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  6. #6
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: WebBrowser control in VB6 -shdocvw.dll not working in Windows 8

    Quote Originally Posted by Bonnie West View Post
    Forgot to mention I tested that code with IE v8. IE8 in XP doesn't have the ActiveDocument parameter for the FileDownload event of the WebBrowser object.
    Quite interesting.

    I wonder if it is really related to the "IE/Shell" separation that started in Windows Vista then?

  7. #7
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: WebBrowser control in VB6 -shdocvw.dll not working in Windows 8

    Quote Originally Posted by dilettante View Post
    I wonder if it is really related to the "IE/Shell" separation that started in Windows Vista then?
    I don't have Vista so I wouldn't know. Sorry...
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  8. #8
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: WebBrowser control in VB6 -shdocvw.dll not working in Windows 8

    Separation of Internet Explorer 7 from the Windows shell talks about it without giving any useful details.

    Since it seems to be more of a an IE7 issue than an OS issue it would apply anywhere you have IE7 or later installed.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width