Modeless Secondary Window

WinCreateSecondaryWindow or WinLoadSecondaryWindow can be used to create a modeless secondary window. WinCreateSecondaryWindow creates a secondary window from a dialog template that is stored in the application's executable file. WinLoadSecondaryWindow creates a secondary window from a dialog template that is stored in a dynamic link library.

If the template is a resource in a dynamic link library, the application loads the dynamic link library by calling DosLoadModule, and then loads the dialog by calling WinLoadSecondaryWindow (or WinSecondaryWindow, which calls WinLoadSecondaryWindow). A WM_INITDLG message is sent to the secondary window procedure before WinLoadSecondaryWindow returns.

#define INCL_SECONDARYWINDOW             /* Secondary window functions */
#include <sw.h>

PDLGTEMPLATE pdlgt;

DosGetResource (NULL, RT_DIALOG, ID_DIALOG, (PVOID) pdlgt);

WinCreateSecondaryWindow ( HWND_DESKTOP, /*  Parent window     */
                NULL                     /*  Owner window      */
                MyDlgProc                /*  Dialog procedure  */
                pdlgt                    /*  Dialog template   */
                NULL);                   /*  Create parameters */

If the template is a resource in the application's executable file, the application loads the resource by calling DosGetResource (as shown in the previous figure) and then uses the template with WinCreateSecondaryWindow to create a secondary window. This method of using a dialog template gives the application the advantage of reviewing and modifying the template before creating the secondary window.

The difference between a modal and a modeless secondary window is the way the windows handle input. For a modal secondary window, WinSecondaryWindow and WinProcessSecondaryWindow handle all user input to the window with an internal message loop and prevent access to other windows in the application. For a modeless secondary window, the application relies on a normal message loop to dispatch messages to the secondary window procedure and does not use WinSecondaryWindow or WinProcessSecondaryWindow.


[Back: Creating a Secondary Window]
[Next: Secondary Window Message Box]