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>isdialogok()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
IsDialogOK()
Check whether the GETs in a dialog can be exited
------------------------------------------------------------------------------

Syntax
#include "dialog.ch"
IsDialogOK( <hWndDlg> )   -->   lOK

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

Description
This "function" (it's actually a #xtranslate) is used when you have
a dialog with any GET fields, and want to know whether the dialog
can be terminated successfully.

Most dialogs contain buttons marked Ok/Cancel (or something similar).
For the Ok button, you should use this function to test whether the
GETs are ok (basically, whether a K_PGDN would be acceptable).

Similarly, before cancelling a dialog, you must use the CANCEL
DIALOG command.

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

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 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. nWparam == 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: @ DIALOG ... GET CANCEL DIALOG

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