DEFINE DIALOG Create dialog boxes.
|
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
DIALOG PROPERTIES:
DIALOG METHODS:
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
button.
· IsDlgButtonChecked
(<hWndDialog>,<nIdControl> ) --> boolState
function to check the state of each radio button and check box
Dialog Box Edit Controls
List Boxes, Combo Boxes, and Directory Listings
Dialog Box Control Messages
EXAMPLE: