Select the product you need help with
How To Create Windows in a Multithreaded ApplicationArticle ID: 90975 - View products that this article applies to. This article was previously published under Q90975 SUMMARY
In a multithreaded application, any thread can call the CreateWindow() API
to create a window. There are no restrictions on which thread(s) can create
windows.
It is important to note that the message loop and window procedure for the window must be in the thread that created the window. If a different thread creates the window, the window won't get messages from DispatchMessage(), but will get messages from other sources. Therefore, the window will appear but won't show activation or repaint, cannot be moved, won't receive mouse messages, and so on. MORE INFORMATION
Normally, windows created in different threads process input independently
of each other. The windows have their own input states and the threads are
not synchronized with eachother in regards to input processing.
In order to have threads to share input state, have one thread call AttachThreadInput() to have its input processing attached to another thread. What this means is that these two threads will use a Windows 3.1 style system queue. The threads will still have separate input, but they will take turns reading out of the same queue. Creating a window can force an implicit AttachThreadInput(), when a parent window is created in one thread and the child window is being created in another thread. When windows are created (or set) in separate threads with a parent-child relationship, the input queues are attached. On Windows NT/2000, you cannot use AttachThreadInput() to attach a thread to a thread in another desktop. PropertiesArticle ID: 90975 - Last Review: July 11, 2005 - Revision: 1.3
|


Back to the top








