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>@ dialog ... get</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
@ DIALOG ... GET
GET validated data at a specified dialog position
------------------------------------------------------------------------------

Syntax
#include "dialog.ch"
@ DIALOG <hWndDlg>
           ID <nId>
           GET <xVar>
           [ PICTURE <cPicture> ]
           [ WHEN <lWhen> ]
           [ VALID <lValid> ]
           [ FONT <hFont> ]
           [ SEND <msg> ]

Arguments
<hWndDlg> is the handle of the dialog to contain the GET
field.

<nId> is the numeric id of the edit control which is to be
used for the GET.

<xVar> is the variable to be input.

<cPicture> is an optional picture string.

<lWhen> is an optional pre-condition that must be TRUE to
allow changes to the variable.

<lValid> is an optional post-condition that must be TRUE to
allow changes to be assigned to the variable.

<hFont> is an optional font to be used.

<msg> is an optional command to the GET.

Description
This command can be used to input data in a dialog, with control
over the font type and size, as well as the validation used.

This command is used to replace an edit control in the dialog
with a GET field.  You do this at the start of dialog, when
you get the WM_INITDIALOG message.

This command adds information to the GetList variable, which
should be initialised to an empty array (and is usually declared
as a STATIC).

You need to be using dialog resources to use this command.

Most dialogs contain buttons marked Ok/Cancel (or something
similar).  For the Ok button, you should test whether the GETs
are ok (basically, whether a K_PGDN would be acceptable), using
the IsDialogOK() "function" (it's actually a #xtranslate).
Before cancelling a dialog, you must use the CANCEL DIALOG command.
If you use a dialog with style WS_SYSMENU, you will also need to
do this for a WM_SYSCOMMAND message, where the nwParam value is
SC_CLOSE.  See below, and the sample dialog.prg.

You can choose a font either using something like:

          @ DIALOG hDlg ID ID_MYEDIT GET nVar          ;
            FONT GetStockObject(ANSI_VAR_FONT)

which uses one of the pre-defined fonts, or use a font from
CreateFont() or ChooseFont().

Example
#include "dialog.ch"

#ifdef DO_MODAL

// start a modal dialog, processing Windows messages using the
// function below
nRet = DialogBox(  , "dlg",  ,                                ;
                 { | hWndDlg, msg, wparam, lparam |           ;
                   DemoDialog( hWndDlg, msg, wparam, lparam ) } )

#else

// start a modeless dialog, processing Windows messages using the
// function below
hWnd = CreateDialog(  , "dlg",  ,                                ;
                    { | hWndDlg, msg, wparam, lparam |           ;
                      DemoDialog( hWndDlg, msg, wparam, lparam ) } )

#endif // DO_MODAL

//   .
//   .
//   .


//  Handle the messages for the dialog

function DemoDialog( hWndDlg, nMsg, nwParam, nlParam )
local     i, j
static    GetList
local     nVar
local     nVar2
local     nVar3
local     dVar

do case
case nMsg == WM_INITDIALOG

     GetList := { }      // NOTE: need to initialise like this

     nVar = 0
     @ dialog hWndDlg id IDD_EDIT get nVar picture "999.99"

     dVar = ctod("")
     @ dialog hWndDlg id IDD_EDITB get dVar picture "@D"

     nVar2 = 0
     @ dialog hWndDlg id IDD_EDITB get nVar2 when nVar2 < 15      ;
       font GetStockObject(ANSI_FIXED_FONT) range 1,50

     nVar3 = 0
     @ dialog hWndDlg id IDD_EDITC get nVar3                      ;
       font GetStockObject(SYSTEM_FIXED_FONT) valid valchk(nVar3)

     return .t.               // want system to set the focus

case nMsg == WM_SYSCOMMAND

     if nwParam == SC_CLOSE
          CANCEL DIALOG hWndDlg
     endif

case nMsg == WM_COMMAND

     do case
     case nwParam == IDD_OK             ;
     .or. nWparam == IDOK               ;
     .or. nWparam == IDYES

          if IsDialogOK(hWndDlg, nwParam)
#ifdef DO_MODAL
               EndDialog(hWndDlg, nwParam)
#else
               DestroyWindow(hWndDlg)
#endif // DO_MODAL
          endif

     case nWparam == IDCANCEL         ;
     .or. nWpnWparam == IDABORT       ;
     .or. nWparam == IDNO

          CANCEL DIALOG hWndDlg

#ifdef DO_MODAL
          EndDialog(hWndDlg, nwParam)
#else
          DestroyWindow(hWndDlg)
#endif DO_MODAL

     endcase

     return .t.          // means msg has been processed
// . . .


See Also: CANCEL DIALOG IsDialogOK()

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