Jump to content

WinDismissDlg

From EDM2

This function hides the modeless dialog window, and causes WinProcessDlg or WinDlgBox to return.

Syntax

WinDismissDlg(hwndDlg, usResult)

Parameters

hwndDlg (HWND) - input
Dialog-window handle.
usResult (ULONG) - input
Reply value.
Returned to the caller of WinProcessDlg or WinDlgBox.

Returns

rc (BOOL) - returns
Dialog-dismissed indicator.
TRUE - Dialog successfully dismissed
FALSE - Dialog not successfully dismissed.

Errors

Possible returns from WinGetLastError

PMERR_INVALID_HWND (0x1001): An invalid window handle was specified.

Remarks

This function is required to complete the processing of a modal dialog window and is called from its dialog procedure. It is made implicitly if the dialog procedure passes a WM_COMMAND message to WinDefDlgProc or if a WM_QUIT message is encountered during WinProcessDlg or WinGetDlgMsg.

This function hides the dialog window, and re-enables any windows that were disabled by WinProcessDlg or WinGetDlgMsg.

If the dialog window needs to be processed through WinProcessDlg, after being dismissed, the FF_DLGDISMISSED flag must be reset.

It does not destroy the dialog window; WinDestroyWindow must be issued to destroy the dialog window when it is no longer needed. However, WinDlgBox destroys the dialog window it creates, when the dialog window is dismissed by the use of this function.

This function can be issued during the processing of the the WM_INITDLG (Default Dialogs) message.

Note: This function can be made from a modeless dialog window, although this is not necessary as there is no internal message processing loop. If it is called, the dialog window is hidden and it is the responsibility of the application to destroy the dialog window, if required.

Example Code

This example shows a typical dialog procedure that has both an OK and a Cancel button. If the user selects the OK button, WinDismissDlg is called with a result value of TRUE. If the user selects the Cancel button, WinDismissDlg is called with a result value of FALSE.

#define INCL_WINDIALOGS   /* Window Dialog Mgr Functions  */
#define  ID_ENTER  101;
#define  ID_CANCEL 102;
#include <os2.h>

MPARAM   mpParam1;
HWND    hwnd;

case WM_COMMAND:
     switch (SHORT1FROMMP(mpParam1))
     {
       /* OK button selected */
       case ID_ENTER:
            WinDismissDlg(hwnd, TRUE);
            return (0L);

       /* Cancel button selected */
       case ID_CANCEL:
            WinDismissDlg(hwnd, FALSE);
            return (0L);
     }

Definition

#define INCL_WINDIALOGS /* Or use INCL_WIN, INCL_PM, Also in COMMON section */
#include <os2.h>

HWND     hwndDlg;   /*  Dialog-window handle. */
ULONG    usResult;  /*  Reply value. */
BOOL     rc;        /*  Dialog-dismissed indicator. */

rc = WinDismissDlg(hwndDlg, usResult);

Related Functions

  • WinCreateDlg
  • WinDefDlgProc
  • WinDlgBox
  • WinGetDlgMsg
  • WinLoadDlg
  • WinProcessDlg

Related Messages

  • WM_COMMAND
  • WM_QUIT
  • WM_INITDLG (Default Dialogs)