Previous Icon 3

Next Icon 3

Interactions with variable dialogs

It is possible to interact with variable dialogs. Selections in lists, changes in input fields, and selections in lists, can trigger callbacks to a user-defined function. Then, it is also possible to change dialog elements from this callback routine.

You set a local function as a callback via the title input in the variable dialog:

res = CADH_VarDialog([[“Title“,PROC(Callback)], Width, Height, Pitch], [Dialogelement1], [Dialogelement2], ...);

The local callback function will now be called up if there are changes in the dialog. The function is declared as follows:

PAR res;  
 
PROC Callback  
PAR handle, elemNo, event, eventPar;  
 
IF TYP(elemNo)=STRING THEN  
    IF elemNo='@combo' AND event=C:CBN_SELCHANGE THEN  
        IF eventPar=0 THEN  // own input, enable input  
            CADH_VarDialogAccess(handle,[['@input1',C:VDLG_ENABLE,TRUE]]);  
        ELSE  // disable input, set value to zero  
            CADH_VarDialogAccess(handle,[['@input1',C:VDLG_ENABLE,FALSE],  
                                         ['@input1',c:VDLG_ASSIGN,0]]);  
        ENDIF  
    ENDIF  
ENDIF  
ENDPROC  
 
res = CADH_VarDialog([['Title',PROC(Callback)], 400, 400 0.4],  
                      [[C:VDLG_Real,'@input1'],'Input1:',2],  
                      [[C:VDLG_StrCom,'@combo'],'Selection:',  
                          ['own input','calculate'],[0],TRUE]);

 

A handle is transferred to the dialog as a code parameter, along with an element identifier, the event, and additional parameters. The possible events are:

Element type

Event

Parameter

Dialog

Initialization

none

 

WM_INITDIALOG

 

Combobox

Selection

Current value

 

CBN_SELCHANGE

 

Input field

Leave field

Current value

 

WM_KILLFOCUS

 

 

 

Button

activated

none

 

BN_CLICKED

 

Either the number of the element according to the index in the results array is transferred as the element number, or the name of the element is transferred. As in the example, a name can be defined by transferring an array, with a type and name in its first element, for the dialog element.

Use this function to access the dialog from the callback routine:

CADH_VarDialogAccess(handle, [[elemNo, action, param],[elemNo, action, param],...]

Here, the following actions are permitted:

Action

Description

Parameter

VDLG_ASSIGN

Assignment to input field

New value

VDLG_SELECT

Selection in combo box

[position]/value

VDLG_ENABLE

Activate or deactivate

TRUE/FALSE

VDLG_SETFOCUS

Focus on new element

Element's ID

If no action is specified, the value in the input field will be returned. The data is returned as an array, with as many elements as code parameters.