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>modaldialog()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
ModalDialog()
Display and activate a modal dialog box
------------------------------------------------------------------------------

Syntax
ModalDialog( <aDlg>, <hInst>, <hWnd> , [ <bAction> ] )   -->   nRet

Arguments
<aDlg> is an array used to describe the dialog.  It must have
been obtained originally from CreateDialog().

<hInst> is the handle of the instance of the application.  (As
returned by the _GetInstance() function.)

<hWnd> is the handle to the window to be the parent of the
dialog.

<bAction> is an optional code block, allowing a dynamic dialog
to be handled in the same way as a resource dialog.  See the
DialogBox() function.

Returns
If successful, a non-negative (but possibly zero) integer is
returned, which indicates the reason the dialog was
terminated.  Otherwise, -1 is returned.

Zero (0) is returned if the user cancels the dialog (e.g. by
pressing the Esc key).

Description
This function is used to display and activate a dialog
previously set up using the CreateDialog() and AppendDialog()
functions.  The return value can be used with the
GetDialogResult() function to determine the outcome of the
dialog.

See the DialogBox() function for details of using the optional
<bAction> code block.  Also, you should use numeric id's
with AppendDialog() if you plan to use the <bAction> code block.

If the dialog contained any user-alterable settings or text
you should not use the new values if the user cancelled the
dialog.

If you have a data-driven application, you may still be able
to use resource dialogs, e.g. with DialogBox(), because you
can alter dialogs during the WM_INITDIALOG message.  Among
other things, you can enable/disable controls, hide them,
and/or move them outside the visible part of the dialog.   See
the source\dialog.prg sample for some ideas.

Example

aDlg = CreateDialog("Sample Dialog",                         ;
                    WS_CAPTION +  WS_SYSMENU                 ;
                    + WS_GROUP + WS_TABSTOP                  ;
                    + WS_THICKFRAME + WS_VISIBLE             ;
                    + WS_POPUP,                              ;
                    24, 12, 180, 160)


aDlg = AppendDialog(aDlg, "ckbox", DLG_BUTTON,               ;
                    BS_CHECKBOX + WS_TABSTOP + WS_CHILD      ;
                    + WS_VISIBLE,                            ;
                    60, 90, 45, 12,                          ;
                    "&Check box")

aDlg = AppendDialog(aDlg, "ok", DLG_BUTTON,                  ;
                    BS_DEFPUSHBUTTON + WS_TABSTOP            ;
                    + WS_CHILD + WS_VISIBLE,                 ;
                    136, 112, 24, 14,                        ;
                    "&Ok")

// Hitting ESCAPE returns 0, in case you want to try it...
?  You chose item", i := ModalDialog(aDlg, hInst, hWnd)


See Also: AppendDialog() CreateDialog() GetDialogResult()

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