PRB: Internet Explorer Events Are Not Captured Under the Visual Basic IDE (293375)



The information in this article applies to:

  • Microsoft Internet Explorer (Programming) 4.01
  • Microsoft Internet Explorer (Programming) 4.01 SP1
  • Microsoft Internet Explorer (Programming) 4.01 SP2
  • Microsoft Internet Explorer (Programming) 5
  • Microsoft Internet Explorer (Programming) 5.01
  • Microsoft Internet Explorer (Programming) 5.5
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0 SP3
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0 SP4
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0 SP5

This article was previously published under Q293375

SYMPTOMS

When you run a Microsoft Visual Basic application that includes a WebBrowser object in the Visual Basic IDE, the application may not execute the event handler for the FileDownload event when the browser is about to download a file. You may experience similar behavior with other WebBrowser control (Internet Explorer) events.

CAUSE

This problem occurs because Visual Basic 6.0 is single-threaded and Internet Explorer 4.0 or later is apartment-threaded. Because this problem originates from a threading issue, you cannot always reproduce the problem.

RESOLUTION

When your project runs outside the Visual Basic environment, the event handler for the FileDownload event and for other events is executed as expected. For more information about how to reproduce the problem, see the "More Information" section of this article.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Create a new Standard EXE project in Visual Basic 6.0. By default, Form1 is created.
  2. Add the Microsoft Internet Controls component to Form1.
  3. Add a WebBrowser control to Form1.
  4. Add the following code to the project:
    Private Sub Form_Load()
    ' Use any URL that points to an .exe file.
    WebBrowser1.Navigate2 & _
    "http://download.microsoft.com/download/ie6sp1/finrel/6_sp1/W98NT42KMeXP/EN-US/ie6setup.exe
    
    End Sub
    
    Private Sub WebBrowser1_FileDownload(Cancel As Boolean)
        MsgBox "FileDownLoad event has fired."
    End Sub
    					
  5. Run the project inside the Visual Basic environment. Notice that you do not receive the FileDownload event.
  6. Compile and then run Project1.exe. A message box appears where you can receive the event.

REFERENCES

The following file is available for download from the Microsoft Download Center:
For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.

For more information, visit the following Microsoft Developer Network (MSDN) Web site: For more information about the FileDownload event, visit the following MSDN Web site: For more information about developing Web-based solutions for Microsoft Internet Explorer, visit the following MSDN Web sites:

Modification Type:MajorLast Reviewed:4/21/2006
Keywords:kbdownload kbdownload kbfile kbnofix kbprb kbWebBrowser KB293375 kbAudDeveloper