Microsoft KB Archive/293375

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

Article ID: 293375

Article Last Modified on 5/13/2007

-

APPLIES TO


 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Internet Explorer 4.01 Service Pack 1
 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Internet Explorer 5.0
 * Microsoft Internet Explorer 5.01
 * Microsoft Internet Explorer 5.5
 * Microsoft Visual Basic 6.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition Service Pack 3
 * Microsoft Visual Basic 6.0 Enterprise Edition Service Pack 4
 * Microsoft Visual Basic 6.0 Enterprise Edition Service Pack 5

-



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 &quot;More Information&quot; section of this article.



Steps to Reproduce the Behavior
 Create a new Standard EXE project in Visual Basic 6.0. By default, Form1 is created. Add the Microsoft Internet Controls component to Form1. Add a WebBrowser control to Form1.  Add the following code to the project: Private Sub Form_Load ' Use any URL that points to an .exe file. WebBrowser1.Navigate2 & _ &quot;http://download.microsoft.com/download/ie6sp1/finrel/6_sp1/W98NT42KMeXP/EN-US/ie6setup.exe

End Sub

Private Sub WebBrowser1_FileDownload(Cancel As Boolean) MsgBox &quot;FileDownLoad event has fired.&quot; End Sub  Run the project inside the Visual Basic environment. Notice that you do not receive the FileDownload event. Compile and then run Project1.exe. A message box appears where you can receive the event.</li></ol>

<div class="references_section">