// JP opened flex table

Click to See Complete Forum and Search --> : Window messages and threads


Lindley
January 16th, 2008, 08:56 AM
I'm trying to tack on the ability to show a window to an existing non-windowed program. That means I don't have my main thread running an event loop.

I had thought to just spawn a thread which would create a window, then run an event loop. I figured I could update the contents of the window from another thread using a mutex, and just let that one thread handle all window stuff.

However, this doesn't appear to work----the window behaves as if its events aren't being processed. The documentation I found for the GetQueueStatus etc functions indicates they're per-thread, but I'm not sure what it means for a window to *belong* to a thread. I thought that just meant the window was created in that thread...but perhaps not, since it isn't working.

What's the deal here?

Igor Vartanov
January 16th, 2008, 09:16 AM
I'm not sure what it means for a window to *belong* to a thread.
Each thread, that creates a window, gets "equipped" with separate message queue, and all messages posted to windows, that have been created by the thread, are processed there. Also, while the message is sent to a window, the execution context is switched to a window's thread context while in SendMessage.

Lindley
January 16th, 2008, 09:22 AM
Okay, so I'm not sure why processing events in a secondary thread isn't working, if that same thread created the window.

Lindley
January 16th, 2008, 09:37 AM
EDIT: Nevermind, found the problem. Forgot a mutex unlock.

//JP added flex table