Dialog Boxes

Communication between a standard window and a modeless dialog box is achieved in a similar fashion to that used between two standard windows, since the modeless dialog box is merely a normal window without a sizable border. However, communication between a standard window and a modal dialog box must be achieved in a different manner, since a modal dialog box is typically loaded and processed in a single WinDlgBox() function call, and the dialog box only has an existence during the execution of that function call. An example of the WinDlgBox() function is shown in Figure "WinDlgBox() Function".

Data may be passed to a dialog procedure at initialization time by creating a data structure and passing a pointer to that structure in the CreateParams field of the WinDlgBox() function, as shown in Figure "WinDlgBox() Function". This pointer is passed to the dialog procedure as the second parameter of the WM_INITDLG message, and may be accessed by the dialog procedure during the processing of this message. Note that this is the only time at which input may be passed to a dialog box, since the dialog is processed within the scope of a single application statement; either a WinDlgBox() call or a WinProcessDlg() call may be used. The WM_INITDLG message is described in the IBM OS/2 Version 2.0 Presentation Manager Reference.

Information may be conveyed from a dialog procedure to its calling window procedure in one of two ways:

  • The dialog box may provide an unsigned integer (USHORT) parameter to the WinDismissDlg() function, and this value is passed to the calling window procedure as the return code from the WinDlgBox() function. This technique is useful where an acknowledgement or simple return data must be conveyed.

  • The dialog box may issue a WinPostMsg() call to pass a message to the queue associated with its calling window. The window procedure may then receive and process that message in the normal way. This technique is useful when more complex data or structures must be conveyed.

    The latter technique above may also be used to convey information to a window other than the window that invoked the dialog. This may be necessary in situations where a dialog box is invoked by one window procedure on behalf of a group of windows.


    [Back: Standard Windows]
    [Next: Control Windows]