Standard Windows

Data may be passed to a window upon its creation, using the CtlData parameter of the WinCreateWindow() function. The contents of this parameter (a 32-bit pointer) are passed to the target window as a parameter to the WM_CREATE message. The contents may then be extracted from the message parameter and used by the window procedure.

When an application wishes to pass a message between two standard windows that currently exist, whether they are display windows or object windows, either of two methods may be used, depending on whether the desired communication is to be synchronous or asynchronous.

  • When a synchronous message is to be passed, the WinSendMsg() function is used, and the target window procedure is invoked directly by Presentation Manager, in a similar fashion to a normal function call. The return code from the window procedure is passed by Presentation Manager to the calling window procedure, where it may be interrogated and acted upon.

  • When a message is to be processed asynchronously, the WinPostMsg() function is used. In this case the message is posted to a queue associated with the thread that created the target window, and the return code to the calling window procedure merely indicates that the message was successfully placed on the queue. In order for the target window procedure to pass a return code or acknowledgement back to the calling window procedure, it must include another WinPostMsg() call as part of the processing of the message.

    The use of WinPostMsg() is recommended over that of WinSendMsg(), since posted messages are processed in the order in which they arrive in the queue, and the integrity of the user's intention is thus preserved in the order of processing. In addition, synchronous window procedures are invoked and executed without the original window procedure completing its processing and returning control to the message processing loop. Thus the application is prevented from processing additional user interaction, which may lead to violation of the SAA CUA responsiveness guidelines.


    [Back: Window Communication]
    [Next: Dialog Boxes]