DEFINE DIALOG 
Create dialog boxes.
  

A dialog box is a temporary window an application creates to retrieve user input. An application typically uses dialog boxes to prompt the user for additional information for menu items. A dialog box usually contains one or more controls (child windows) with which the user enters text, chooses options, or directs the action.

SYNTAX

Dialog box from resources

DEFINE DIALOG <DialogName>
[ OF | PARENT> <
ParentWindowName> ]
RESOURCE <
nIdResource>
[ CAPTION <
cCaption> ]
[ FONT <
cFontName> ]
[ SIZE <
nFontSize> ]
[ BOLD ]
[ ITALIC ]
[ DIALOGPROC <
DialogProcedureName> | <bBlock> ]
[ ON INIT <
InitProcedureName> | <bBlock> ]
[ ON RELEASE <
ReleaseProcedureName> | <bBlock> ]

... Control Redefinitions...

END DIALOG

Modal Dialog box from resources

DEFINE DIALOG <DialogName>
[ OF | PARENT> <
ParentWindowName> ]
RESOURCE <
nIdResource>
[ CAPTION <
cCaption> ]
[ FONT <
cFontName> ]
[ SIZE <
nFontSize> ]
[ BOLD ]
[ ITALIC ]
MODAL
[ DIALOGPROC <
DialogProcedureName> | <bBlock> ]
[ ON INIT <
InitProcedureName> | <bBlock> ]
[ ON RELEASE <
ReleaseProcedureName> | <bBlock> ]

..............

Control Redefinitions

..............

END DIALOG

Dialog box without using resources

DEFINE DIALOG <DialogName>
[ OF | PARENT> <
ParentWindowName> ]
AT <
nRow>,<nCol>
WIDTH <
nWidth
HEIGHT <
nHeight>
[ CAPTION <
cCaption> ]
[ FONT <
cFontName> ]
[ SIZE <
nFontSize> ]
[ BOLD ]
[ ITALIC ]
[ MODAL ]
[ DIALOGPROC <
DialogProcedureName> | <bBlock> ]
[ ON INIT <
InitProcedureName> | <bBlock> ]
[ ON RELEASE <
ReleaseProcedureName> | <bBlock> ]

... Control Definitions...

END DIALOG

NOTE:

It is possible to call out in double method DIALOGPRC :

·     Any DialogFunction, - then it can be used in function predefined variables:

      DLG_HWND     - Dialog Handle
      DLG_MSG        - Dialog Message
      DLG_ID            - Dialog Id
      DLG_NOT        - Dialog Notification

Example:

Function DialogFun(lOk, nNewAge)
Local   ret := 0, cValue
if DLG_ID != Nil
  do case
  case DLG_ID == IDOK .and. DLG_NOT ==0
    _ReleaseDialog ( )
  case DLG_ID == IDCANCEL .and. DLG_NOT ==0
    _ReleaseDialog ( )
  case DLG_ID == IDC_EDT1 .and. DLG_NOT ==1024
    cValue := GetEditText (DLG_HWND, IDC_EDT1  )
    if !empty(cValue)
       EnableDialogItem (DLG_HWND, IDC_BTN1)
    else
       DisableDialogItem (DLG_HWND, IDC_BTN1)
    endif
  case DLG_ID == IDC_BTN1 .and. DLG_NOT ==0
    ret := GetEditText (DLG_HWND, IDC_EDT1  )
    nNewAge := ret
    lOk := .t.
    _ReleaseDialog ( )
  case DLG_ID == IDC_BTN2 .and. DLG_NOT ==0
    SetDialogItemText(DLG_HWND, IDC_EDT1 ,"  " )
    DisableDialogItem (DLG_HWND, IDC_BTN1)  
  case DLG_ID == IDC_BTN3 .and. DLG_NOT ==0
    _ReleaseDialog ( )
  endcase
endif
Return ret

·     CodeBlok in form {|x,y,z| DialogFunction(x,y,z) }
Particular parameters mark:
      x - Dialog Message
      y - Dialog Id
      z - Dialog Notification

Typically, the dialog box procedure should return TRUE if it processed the message, and FALSE if it did not. If the dialog box procedure returns FALSE, the dialog manager performs the default dialog operation in response to the message.


DIALOG PROPERTIES:

·     Title
·     NotifyIcon
·     NotifyToolTip
·     FocusedControl
·     Cursor (R)
·     Name (R)

DIALOG METHODS:

·     Show
·     Hide
·     Center
·     Maximize
·     Minimize
·     Activate
·     Restore
·     Release
·     SetFocus

COMMANDS

- SET DIALOGBOX [ POSITION ] ROW <nRow>|<@VarCodeBlockRow>|<NIL> COL <nCol>|<@VarCodeBlockCol>|<NIL>
- SET DIALOGBOX [ POSITION ] CENTER OF PARENT
- SET DIALOGBOX [ POSITION ] CENTER OF <
hWnd>
- SET DIALOGBOX [ POSITION ] CENTER OF DESKTOP
- SET DIALOGBOX [ POSITION ] DISABLE


FUNCTIONS:

The dialog box functions is responsible for initializing the controls to these settings when creating the dialog box. It is also responsible for retrieving the current settings from the controls before destroying the dialog box.

Procedure must call DestroyWindow to close a modeless dialog box.


·     GetDlgCtrlID (<hWndControl> ) --> nIdControl
function returns the identifier for the control identified by the window handle

·      GetDialogItemHandle ( <hWndDialog>,<nIdControl>) --> CtrlHandle
function retrieves a handle to a control in the specified dialog box

·      GetNextDlgGroupItem API function retrieves a handle to the first control in a group of controls that precedes (or follows) the specified control in a dialog box.

·      GetNextDlgTabItem  API function retrieves a handle to the first control that has the WS_TABSTOP style that precedes (or follows) the specified control.

·      IsDialogMessage API function determines whether a message is intended for the specified dialog box and, if it is, processes the message.

·      MapDialogRect function converts the specified dialog box units to screen units (pixels). The function replaces the coordinates in the specified RECT structure with the converted coordinates, which allows the structure to be used to create a dialog box or position a control within a dialog box.

·      SendDlgItemMessage API function sends a message to the specified control in a dialog box.


The methods used to initialize and retrieve settings depend on the type of control.

Radio Buttons and Check Boxes

·     CheckDlgButton (<hWndDialog>,<nIdControl>, <.T./.F.> )
function, which sets or clears the check box

·     CheckRadioButton (<hWndControl>,<nIdFirstRadio>, <nIdLastRadio>, <nIdSelectRadio>)
function to set the appropriate radio button and automatically clear any other radio bu
tton.

·     IsDlgButtonChecked (<hWndDialog>,<nIdControl> ) --> boolState
function to check the state of each radio button and check box

Dialog Box Edit Controls


·     SetDialogItemText ( <hWndDialog>,<nIdControl>, <cText>)
function, which copies text from a specified buffer to the edit control
·     GetDlgItemText (<hWndDialog>,<nIdControl>) --> cText
GetEditText (<
hWndDialog>,<nIdControl>) --> cText
function, which retrieves the text from edit control .
·     GetDlgItemInt
API function, which retrieves the text from the edit control and converts the text to a decimal value. The user types the number in decimal digits.
·     SetDlgItemInt (<hWndDialog>,<nIdControl>, <cNumText>)
converts a signed or unsigned integer to a string of decimal digits.

List Boxes, Combo Boxes, and Directory Listings

·     DlgDirList
API function automatically fills a list box with the filenames in the current directory.
·     DlgDirSelect
API function retrieves the selected filename from the list box.
·     DlgDirListComboBox
function automatically fills a list box portion of the combo box with the filenames in the current directory.
·     DlgDirSelectComboBoxEx
API function retrieves a selected filename from the list box portion.
·     ComboAddString (<hWndControl>, <cText>)
Add a new item to a listbox, combobox, grid or tree.
·     ComboSetString (<hWndControl>, <cText>)
Set a new value in selected item a listbox, combobox, grid or tree.


Dialog Box Control Messages

·     SendDlgItemMessage ()
API function, which is identical to the
SendMessage function, except that it uses a control identifier instead of a window handle to identify the control that is to receive the message.

EXAMPLE:

See demos in :
\Samples\Basic\Dialog
\Samples\Basic\Dialog_2