destroyed, you have a design problem.
You should redesign your logic so that you post to objects that exist. If
decide what is required.
It's not luck that it has worked in for you because 99.9% of times the
CWnd * will stay valid during the life of the thread. it's that 0.1% that
might get you in trouble, which could have been prevented in the first
place.
It's like me getting used to putting _T() around my string literals. My
app is not Unicode, and I'm not planning on switching to it, but it's a
good habit to pickup.
AliR.
"Tom Serface" <tom.nospam@camaswood.com> wrote in message
news:O3HyJ$bZHHA.1220@TK2MSFTNGP03.phx.gbl...
Hi Ali,
That's a good point. I've never had trouble setting a CWnd pointer in
thread code. I typically call the function in the object before the
thread is started with something like:
m_pMyThread.SetStatusWnd(CWnd *)
but your point seems logical. Maybe I've just been lucky in using it a
way it works. One thing that is worth noting is that if the window that
the CWnd * points to goes away (is closed) a call like
m_StatusWnd->SendMessage() will cause a failure whereas the call to
SendMessage() with an handle will simple be ignored.
Tom
"AliR (VC++ MVP)" <AliR@online.nospam> wrote in message
news:b1DJh.3013$Qw.2264@newssvr29.news.prodigy.net...
I would pass the HWND instead of the CWnd, you never know CWnd my not
be thread safe. Or the CWnd object might get destroyed without the
thread knowing about it.
AliR.