Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

This article was previously published under Q293375

↑ Back to the top


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.

↑ Back to the top


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.

↑ Back to the top


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.

↑ Back to the top


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.

↑ Back to the top


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:
Reference for Visual Basic Developers
http://msdn2.microsoft.com/en-us/library/Aa752043.aspx
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:

↑ Back to the top


Keywords: kbdownload, kbnofix, kbwebbrowser, kbfile, kbprb, KB293375

↑ Back to the top

Article Info
Article ID : 293375
Revision : 8
Created on : 5/13/2007
Published on : 5/13/2007
Exists online : False
Views : 499