Object windows may be created and placed into dynamic link libraries in a similar manner to that already explained for display windows. However, object windows have an additional complication in that they are frequently created in secondary threads in order to handle long-running application tasks.
The steps in creating an object window for inclusion in a DLL are therefore as follows:
Note that the routine called by the application does not return the handle of the newly created window. Indeed, it cannot do so, since the creation of the window takes place asynchronously, in a secondary thread.
This obstacle is overcome by having the calling application (typically a window procedure) pass its own window handle as a parameter. This is passed to the object window, which then passes an acknowledgement message to the calling window procedure, containing its window handle. The calling window procedure may subsequently communicate with or subclass the object window as required. This technique is described, along with an example, in Threads Containing Object Windows.