"BobAchgill" <Bo********@discussions.microsoft.com> wrote in message
news:E9**********************************@microsof t.com...
This what I found at one of the links... something about a piece of
AxWebbrowser hanging around forever in memory after closing a forms
application that has axwebbrowser imbedded. I guess the Try blocks you
suggest will help cosmetically by supressing the message but will the
issue
of the memory decay be a problem. I followed the link that this guy
suggests
for the fix but I did not understand the code. It did not apprear to be
VB
.net code.
This is because it's written in C++ and not VB :)
All the code is telling you to do is to inherit from
SHDocVw.DWebBrowserEvents2 and implement the method WindowClosing. So...in
other words (and not testing this code, just re-writing in VB for ya):
Public (override??) Sub WindowClosing( _
ByVal IsChildWindow As Boolean, _
ByRef Cancel As Boolean _
)
MsgBox("WindowClosing")
End Sub
At the end of InitializeComponent method:
Dim pConPtCon As UCOMIConnectionPointContainer = DirectCast( _
Me.axWebBrowser1.GetOcx(), _
UCOMIConnectionPointContainer _
)
Dim pConPt As UCOMIConnectionPoint
Dim guid As GUID = GetType(SHDocVw.DWebBrowserEvents2).GUID
pConPtCon.FindConnectionPoint(guid, pConPt)
IEEvents e = new IEEvents()
' Make sure you declare private int dwCookie in the form class, but outside
' this method.
pConPt.Advise(e, dwCookie)
--------
Add the following lines of code to the beginning of the Forms Close handler
method.
Dim pConPtCon As UCOMIConnectionPointContainer = DirectCast( _
Me.axWebBrowser1.GetOcx(), _
UCOMIConnectionPointContainer _
)
Dim pConPt As UCOMIConnectionPoint
Dim guid As Guid = GetType(SHDocVw.DWebBrowserEvents2).GUID
pConPtCon.FindConnectionPoint(guid, pConPt)
pConPt.Unadvise(dwCookie)
---------
Once again, I haven't tested this, and wrote it using the code from the link
previously provided. Take not the comment regarding dwCookie inline in the
re-written code.
HTH :)
Mythran