The information in this article applies to:
- Microsoft Visual Basic Control Creation, Professional, and Enterprise
Editions for Windows, version 5.0
- Microsoft Internet Explorer (Programming), version 4.0
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
Resolution for UserDocuments
Make your project an ActiveX EXE. Out-of-process (EXE) projects do not have
this problem. Following are the steps to convert an existing ActiveX DLL
project into an ActiveX EXE project:
- Unregister the ActiveX DLL from your development machine. Use the
REGSVR32.EXE utility with /U parameter. For example, to unregister an
DLL called MYPROJ.DLL, navigate to the directory where the DLL is loaded
and type REGSVR32 /U MYPROJ.DLL.
- Rename the ActiveX DLL. Use another file name that will only be used for
providing Binary compatibility. For example, Comp_OLDNAME.DLL where
OLDNAME is the name of your original DLL.
- From the Project properties General Tab, change Project Type from
ActiveX DLL to ActiveX EXE.
- From the Project properties Component Tab, specify Binary Compatibility
on the Comp_OLDNAME.DLL
- Compile your project to create an ActiveX EXE.
Resolution for UserControls
Make your project Single-threaded and make sure that Internet Explorer 4.0
Active Desktop is enabled on machines where your control is going to be
used.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. We are researching this bug and will post
new information here in the Microsoft Knowledge Base as it becomes
available.
MORE INFORMATION
Steps to Reproduce Behavior
- Create a new ActiveX DLL project.
- From the Project properties, General, change threading model to be
"Apartment Threaded."
- Create a procedure to write debug messages to a file in your project
directory. Cut and paste the following code into your userdocument:
Sub OutputDebug(iStr As String)
Dim H As Integer
H = FreeFile
Open App.Path + "\" + App.EXEName + "_Debug.TXT" For Append As #H
Print #H, iStr
Close #H
End Sub
- Add the following code to the Show and Hide events of your UserDocument:
Private Sub UserDocument_Hide()
OutputDebug "UserDocument_Hide"
End Sub
Private Sub UserDocument_Show()
OutputDebug "UserDocument_Show"
End Sub
- Save your project.
- Compile the ActiveX DLL. Go into the Project Properties, Component and
set Binary Compatibility to your ActiveX DLL.
- Save your project again.
- From Internet Explorer 4.0, navigate to .VBD file for your project. Wait
for your userdocument to display.
- From Internet Explorer 4.0, navigate to a new location such as
www.microsoft.com.
- Exit Internet Explorer 4.0.
- Examine the PROJNAME_debug.txt file in your project directory. Note
that there is no Hide event message in the file. This indicates that the
Hide event was never fired.