WM_DESTROY getting posted and causing ObjectDisposedException

C

Chris Karcher

My application does some dynamic control generation and I can see
(using OpenNETCF's IMessageFilter) that sometimes, after creating the
controls, a WM_DESTROY message will get posted to my application.
This message gets dispatched by ApplicationEx via DispatchMessage()
and will then sometimes dispose a control, later causing an
ObjectDisposedException when trying to interact with that control.

My Question: Why the heck would a WM_DESTROY message get posted to my
message queue?

I thought it might be due to a low memory situation, the OS trying to
tell my application it needs to quit. However, there was almost 2MB
of free memory on the device the last time I received this message.

The application is creating and manipulating all standard .NET
controls (e.g. textboxes, labels), with the exception of the
OpenNETCF's HTMLViewer from v1.1 of the framework. What's interesting
is that about half the time, the Hwnd value in the WM_DESTROY message
will be the value of the m_control handle of the ControlMessageWindow
object wrapped by HTMLViewer.

I really have no idea what's going on here.
 
P

Paul G. Tobey [eMVP]

What HTML is being loaded? You can have JavaScript in the HTML that will
attempt to close the browser window. That might cause the parent of the
HTML control to get a WM_DESTROY, I suppose...

Paul T.
 
C

Chris Karcher

What HTML is being loaded? You can have JavaScript in the HTML that will
attempt to close the browser window. That might cause the parent of the
HTML control to get a WM_DESTROY, I suppose...

Paul T.

It's just simple HTML. No javascript involved.

The HTMLViewer control wraps the native control in "htmlview.dll". In
the lifetime of my application, I create and discard many HTMLViewers
that get collected by the GC, as far as I know. I wonder if the
native control is doing something weird like generating the Destroy
message which then gets posted to the wrong message queue. Is
something like that even possible?
 
P

Paul G. Tobey [eMVP]

I have no idea. I don't program for Windows Mobile all that much. I'm
mostly Windows CE. I would think that the window handle to which the
message was posted would never be mistaken for the wrong window in a short
period of time. You could try not disposing multiple instances of the
control, keeping one around and just using it when you need it, to see if
that's related.

Paul T.
 
C

Chris Karcher

So, I'm 99% certain it was the HTMLViewer. I created an application
only containing HTMLViewer's and was able to reproduce the issue.
After removing the HTMLViewer contained in the main application, I
haven't seen the exception in over a month.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top