Problem:
How to make a Dialog System entry field read-only at runtime?
Resolution:
There may be an occasion where you have an entry field that you want to disable but allow the user to click on the field or be able to select the text and copy it. Disabling the field or making it a DISPLAY-FIELD won't allow the user to select it though.
One way to do this is to use the Dsobjcfg Dialog System Extension.
You can use the CALLOUT function to call Dsobjcfg in order to dynamically alter properties of certain objects, including entry fields. See the Dialog System Help topic "Calling DSOBJCFG" for the implementation details.
The attached demo has 3 radio buttons that allow you to select the entry field that you want to be read-only. You then click the "Read Only" button or the "Not Read Only" button to turn this attribute of the entry field on or off. The datablock should contain the following group:
DSOBJCFG-PARAMETERS 1
DSOBJCFG-OBJECT C5 4.0
DSOBJCFG-CHANGE-MODE C 1.0
DSOBJCFG-PARENT-HANDLE C5 4.0
DSOBJCFG-CHANGE-ITEM X 4.0
DSOBJCFG-NEW-VALUE-1 C5 4.0
DSOBJCFG-NEW-VALUE-2 C5 4.0
DSOBJCFG-STATUS-1 C 1.0
DSOBJCFG-STATUS-2 C5 2.0
DSOBJCFG-OBJECT must contain the object id for the entry field. You get this using the MOVE-OBJECT-ID function. DSOBJCFG-CHANGE-MODE must have the value 2 which means to change the entry field object only, not the screenset data. DSOBJCFG-PARENT-HANDLE must contain the window handle of the window that contains the entry field. Get this value using the MOVE-OBJECT-HANDLE function. DSOBJCFG-CHANGE-ITEM must have the value "STYL". DSOBJCFG-NEW-VALUE-1 must have the value 16 which indicates the READ-ONLY attribute of the entry field. DSOBJCFG-NEW-VALUE-2 should have the value 1 if you want to have the
READ-ONLY attribute on or the value 0 if you don't want it on. Please see the code for the
WINDOW-CREATED event of the WIN-01 window, and the BUTTON-SELECTED events for the radio buttons, the "Read Only" button, and the "Not Read Only" button to see these values set.