This article was previously published under Q90975
In a multithreaded application, any thread can call the CreateWindow() APIto create a window. There are no restrictions on which thread(s) can createwindows.
It is important to note that the message loop and window procedure for thewindow must be in the thread that created the window. If a different threadcreates the window, the window won't get messages from DispatchMessage(),but will get messages from other sources. Therefore, the window will appearbut won't show activation or repaint, cannot be moved, won't receive mousemessages, and so on.
Normally, windows created in different threads process input independentlyof each other. The windows have their own input states and the threads arenot synchronized with eachother in regards to input processing.
In order to have threads to share input state, have one thread callAttachThreadInput() to have its input processing attached to anotherthread. What this means is that these two threads will use a Windows 3.1style system queue. The threads will still have separate input, but theywill take turns reading out of the same queue.
Creating a window can force an implicit AttachThreadInput(), when a parentwindow is created in one thread and the child window is being created inanother thread. When windows are created (or set) in separate threads witha 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.