CContainedWindow and worker threads 
Author Message
 CContainedWindow and worker threads

I am using an invisible at runtime control that uses a CContainedWindow
object to handle messages that are sent by a worker thread (as per several
past posts on the subject)...

in FinalRelease() i have:

  RECT rect={0,0,0,0};
  m_PumpWnd.Create(NULL, rect,"Pump Window",WS_OVERLAPPED);

things work ok from the message passing perpective...but in FinalRelease()

 i have
    m_PumpWnd.DestroyWindow();
which is throwing an assertion...(hWnd==NULL)....

1) Should or shouldn't i be calling DestroyWindow()?
2) When I use WS_POPUP in the window style during create i do not throw the
assert...
3) do i need m_PumpWnd.ShowWindow(SW_HIDE) when i create this behind the
scenes window....



Sun, 27 Feb 2005 02:54:39 GMT  
 CContainedWindow and worker threads
WS_OVERLAPPED is actually 0 (zero), which instructs CContainedWindow to
use style traits instead, and those specify WS_CHILD style. I'm not sure
why it works though - creation of a child window should have failed when
NULL parent is specified. Are you sure this is the actual code from your
app?

Anyway, you can avoid the problem by specifying any non-zero style, such
as WS_POPUP or WS_OVERLAPPED | WS_BORDER.

I don't think you need ShowWindow(SW_HIDE). A window is created hidden
unless WS_VISIBLE style is specified, and in your case it is not.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> I am using an invisible at runtime control that uses a
CContainedWindow
> object to handle messages that are sent by a worker thread (as per
several
> past posts on the subject)...

> in FinalRelease() i have:

>   RECT rect={0,0,0,0};
>   m_PumpWnd.Create(NULL, rect,"Pump Window",WS_OVERLAPPED);

> things work ok from the message passing perpective...but in
FinalRelease()

>  i have
>     m_PumpWnd.DestroyWindow();
> which is throwing an assertion...(hWnd==NULL)....

> 1) Should or shouldn't i be calling DestroyWindow()?
> 2) When I use WS_POPUP in the window style during create i do not
throw the
> assert...
> 3) do i need m_PumpWnd.ShowWindow(SW_HIDE) when i create this behind
the
> scenes window....



Sun, 27 Feb 2005 03:44:02 GMT  
 CContainedWindow and worker threads
So using WS_POPUP style and calling DestroyWindow() in FinalRelease() is the
way to go...
thanks...


Quote:
> WS_OVERLAPPED is actually 0 (zero), which instructs CContainedWindow to
> use style traits instead, and those specify WS_CHILD style. I'm not sure
> why it works though - creation of a child window should have failed when
> NULL parent is specified. Are you sure this is the actual code from your
> app?

> Anyway, you can avoid the problem by specifying any non-zero style, such
> as WS_POPUP or WS_OVERLAPPED | WS_BORDER.

> I don't think you need ShowWindow(SW_HIDE). A window is created hidden
> unless WS_VISIBLE style is specified, and in your case it is not.
> --
> With best wishes,
>     Igor Tandetnik

> "For every complex problem, there is a solution that is simple, neat,
> and wrong." H.L. Mencken



> > I am using an invisible at runtime control that uses a
> CContainedWindow
> > object to handle messages that are sent by a worker thread (as per
> several
> > past posts on the subject)...

> > in FinalRelease() i have:

> >   RECT rect={0,0,0,0};
> >   m_PumpWnd.Create(NULL, rect,"Pump Window",WS_OVERLAPPED);

> > things work ok from the message passing perpective...but in
> FinalRelease()

> >  i have
> >     m_PumpWnd.DestroyWindow();
> > which is throwing an assertion...(hWnd==NULL)....

> > 1) Should or shouldn't i be calling DestroyWindow()?
> > 2) When I use WS_POPUP in the window style during create i do not
> throw the
> > assert...
> > 3) do i need m_PumpWnd.ShowWindow(SW_HIDE) when i create this behind
> the
> > scenes window....



Sun, 27 Feb 2005 06:22:17 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. worker thread vs main thread?

2. COM Threading Model for ISAPI Worker Threads

3. Handling events from a worker thread in the main thread

4. component in main threads used in worker threads

5. Exe server threading model - events from worker thread question

6. how do i create thread safe worker thread

7. How can i terminate a Worker Thread during a Thread is running?Thank

8. How to Send messages from worker thread to main thread

9. Synchronization problem between main thread and worker thread

10. UI Thread better than Worker thread for speed?

11. Determine if current thread is a worker thread

12. Posting a message from a worker thread to the main app thread

 

 
Powered by phpBB® Forum Software