Microsoft KB Archive/11082

PRB: Exchanging Window Handles Between 2 Cooperating Programs ID Number: Q11082

2.00 2.03 2.10 3.00 WINDOWS

Summary:

SYMPTOMS There are two cooperating programs that have exchanged window handles. One of these programs is serving as a slave to the other, which is called the master. When a user closes the master program, it is necessary to close the slave program’s window and terminate it.

If the window held by the slave is closed by the master program using DestroyWindow, the slave program’s window is destroyed; however, the slave program never receives a WM_DESTROY message.

RESOLUTION Messages are sent to the task that created the window (that is, the master program). Note that the Windows message dispatcher has no means of “knowing” that a window handle has been exchanged.

The correct way to terminate the slave program is to send a WM_DESTROY message using PostAppMessage to the slave program.