Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide to Clip-4-Win version 3.0 - <b>enddialog()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
EndDialog()
Terminate a modal dialog
------------------------------------------------------------------------------

Syntax
EndDialog( <hWndDlg>, <nResult> )   -->   nil

Arguments
<hWndDlg> is the handle of the dialog to be terminated.

<nResult> is the numeric value which will be returned from the
original call to DialogBox() or ModalDialog().  Avoid -1, as
that is used to signal an error in the original DialogBox().
Also, you might want to make use of the values IDOK, IDCANCEL,
IDABORT, IDRETRY, IDIGNORE, IDYES and IDNO, which are defined
in WINDOWS.CH in the range 1 to 7.

Returns
NIL.

Description
This function is used to terminate a modal dialog started by
the DialogBox() or ModalDialog() functions.

Whilst processing the WM_INITDIALOG message, you can prevent a
dialog box from appearing, if you need to, by calling
EndDialog().  This is unusual, but can be useful if you
discover an error.

Example
i = DialogBox(  ,  "dlg",  ,                           ;
             { | hDlg, msg, wparam, lparam |           ;
               ResDlgModal( hDlg, msg, wparam, lparam ) } )

// elsewhere . . .
function ResDlgModal( hWndDlg, nMsg, nwParam, nlParam )
static    nCtrl := IDD_A
local     i
do case
case nMsg == WM_INITDIALOG
     CheckDlgButton( hWndDlg, nCtrl, 1 )
     SendDlgItemMessage( hWndDlg, IDD_EDIT, WM_SETTEXT, 0,  ;
                          "Initial Text" )
     return 1            // want system to set the focus
case nMsg == WM_COMMAND
     do case
     case nwParam == IDD_OK                                 ;
     .or. nWparam == IDOK
          // save the current radio button choice
          nRadio := nCtrl
          // now save the text in the edit control
          i = SendDlgItemMessage( hWndDlg, IDD_EDIT,        ;
                               WM_GETTEXTLENGTH, 0, 0 )
          i++            // include the trailing null (which we don't want!)
          cText = space( i )
          i = SendDlgItemMessage( hWndDlg, IDD_EDIT,        ;
                               WM_GETTEXT, i, @cText )
          // remove the trailing null
          cText = left( cText, i )
          EndDialog( hWndDlg, nwParam )   // *not* DestroyWindow()
          return 1       // means msg has been processed
     case nWparam == IDCANCEL
          // don't change cText
          EndDialog( hWndDlg, nwParam )   // *not* DestroyWindow()
          return 1       // means msg has been processed
     case nWparam == IDABORT       ;
     .or. nWparam == IDRETRY       ;
     .or. nWparam == IDIGNORE      ;
     .or. nWparam == IDYES         ;
     .or. nWparam == IDNO
          // not used in this example
     case nwParam == IDD_EDIT
          if ( i := _LastHilParam() ) == EN_ERRSPACE       ;
          .or. i == EN_MAXTEXT
               MessageBox( hWndDlg, "Edit control full", "Info" )
          endif
     case nwParam == IDD_PUSH
          // start a sub-dialog
          i = DialogBox(  , "dlg2", hWndDlg,                ;
                        { | hDlg, msg, wparam, lparam |     ;
                          ResDlg2( hDlg, msg, wparam, lparam ) } )
          MessageBox( hWndDlg , asString(cText), "Edit Control result" )
     case nwParam == IDD_A
          nCtrl = IDD_A
     case nwParam == IDD_B
          nCtrl = IDD_B
     endcase
endcase
return 0  // means msg not processed (and want default action)


See Also: DialogBox() ModalDialog()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson