FIX: Hide Event Doesn't Fire Correctly in Internet Explorer 4.0
Article ID: 175907
Article Last Modified on 12/10/2003
APPLIES TO
- Microsoft Visual Basic 5.0 Control Creation Edition
- Microsoft Visual Basic 5.0 Professional Edition
- Microsoft Visual Basic 5.0 Enterprise Edition
- Microsoft Internet Explorer 4.0 128-Bit Edition
This article was previously published under Q175907
SYMPTOMS
Code placed in the Hide event of a UserDocument or a UserControl does not
execute under Internet Explorer 4.0. The Hide event does not fire correctly
for the following:
- ActiveX DLL UserDocument with Apartment-threading
- ActiveX DLL UserDocument with Single-threading and absence of Active
Desktop
- ActiveX Control OCX with Apartment-threading
- ActiveX Control OCX with Single-threading and absence of Active
Desktop
CAUSE
The Hide event is not getting fired for UserControl and UserDocument
objects because these objects are being released before receiving the Hide
event. Internet Explorer 3.0 does not have this problem because it
maintains a four-page cache. Internet Explorer 4.0 does not have a four-
page cache.
RESOLUTION
Add the following code to your UserDocument or UserControl module. The self-
reference will keep your object in memory long enough to receive the hide
event, at which point you can free the object reference:
- To the General/Declarations section of your code module, add:
Private objMe As Object
- To the UserDocument_Show or UserControl_Show event, add:
Set objMe = Me
- To the UserDocument_Hide or UserControl_Hide event, add:
Set objMe = Nothing
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. This bug has been fixed in Visual Basic
6.0.
Additional query words: VBD Hide OCX KBiNETdEV kbVBp500bug kbIE400 kbdsi kbVBp600fix
Keywords: kbbug kbfix KB175907