Home All Groups Group Topic Archive Search About

ActiveX control cleanup in IE

Author
19 May 2009 2:21 PM
Bob Butler
I've been working on an activex control to be hosted on a web page.  The
control contains several other user controls which provide unicode-capable
labels, command buttons, text boxes, and list boxes.

Because I'm creating windows and subclassing them it's critical that they be
released properly.  Testing the control on a VB form I was able to rely on
the terminate event but apparently IE only fires that if it's a Tuesday
after a full moon and the stock market is up for the day.  After some
digging I found that a workaround is to use the Hide event instead and that
was working great in win2k and xp using ie6 and/or ie7 but when I got to
Vista it no longer fires.  I've tried watching for WM_CLOSE or WM_DESTROY on
the main usercontrol window but that didn't help either.

I've been able to work around the issue by adding code in the html to call a
cleanup method when the browser fires the onbeforeunload event but that's a
real hack.

Does anybody have any experience with activex controls hosted by ie7 under
Vista?  Any thoughts on how I can detect the user closing the page or
navigating away?

Author
19 May 2009 2:30 PM
Bob Butler
"Bob Butler" <noway@nospam.ever> wrote in message
news:OVNo31I2JHA.4744@TK2MSFTNGP04.phx.gbl...
<cut>
> Does anybody have any experience with activex controls hosted by ie7 under
> Vista?  Any thoughts on how I can detect the user closing the page or
> navigating away?

Of course, after posting I went back and can no longer get IE7 under Vista
to fail.  It fires the Hide event every time just like it does under other
OS versions.

As Emily Litella would say, "Nevermind..."
Author
19 May 2009 5:02 PM
Karl E. Peterson
Bob Butler wrote:
> Of course, after posting I went back and can no longer get [it] to fail.

Cool workaround!  :-)
--
..NET: It's About Trust!
http://vfred.mvps.org
Author
19 May 2009 9:00 PM
Nobody
Show quote Hide quote
"Bob Butler" <noway@nospam.ever> wrote in message
news:er5bK7I2JHA.1096@TK2MSFTNGP06.phx.gbl...
>
> "Bob Butler" <noway@nospam.ever> wrote in message
> news:OVNo31I2JHA.4744@TK2MSFTNGP04.phx.gbl...
> <cut>
>> Does anybody have any experience with activex controls hosted by ie7
>> under Vista?  Any thoughts on how I can detect the user closing the page
>> or navigating away?
>
> Of course, after posting I went back and can no longer get IE7 under Vista
> to fail.  It fires the Hide event every time just like it does under other
> OS versions.
>
> As Emily Litella would say, "Nevermind..."

Does the Terminate event work?

Try switching tabs, and closing tabs without activating them to cover all
situations.
Author
19 May 2009 8:56 PM
DanS
"Bob Butler" <noway@nospam.ever> wrote in
news:OVNo31I2JHA.4744@TK2MSFTNGP04.phx.gbl:

(Top-opsted for brevity)

I'm guessing this is an internal webpage only ???? Like for a companies
employees to use ?







Show quoteHide quote
> I've been working on an activex control to be hosted on a web page.
> The control contains several other user controls which provide
> unicode-capable labels, command buttons, text boxes, and list boxes.
>
> Because I'm creating windows and subclassing them it's critical that
> they be released properly.  Testing the control on a VB form I was
> able to rely on the terminate event but apparently IE only fires that
> if it's a Tuesday after a full moon and the stock market is up for the
> day.  After some digging I found that a workaround is to use the Hide
> event instead and that was working great in win2k and xp using ie6
> and/or ie7 but when I got to Vista it no longer fires.  I've tried
> watching for WM_CLOSE or WM_DESTROY on the main usercontrol window but
> that didn't help either.
>
> I've been able to work around the issue by adding code in the html to
> call a cleanup method when the browser fires the onbeforeunload event
> but that's a real hack.
>
> Does anybody have any experience with activex controls hosted by ie7
> under Vista?  Any thoughts on how I can detect the user closing the
> page or navigating away?