Kbase P103563: ADM1: How to disable SmartViewer Object field given its name from anywhere in the application?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  4/22/2005 |
|
Status: Unverified
GOAL:
ADM1: How to disable SmartViewer Object field given its name from anywhere in the application?
FACT(s) (Environment):
Windows
Progress 8.x
FIX:
One approach to define a local procedure in your ADM1 version 8.x SmartViewer to return the handle of a field given that field's name. Once you have that handle, you can enable or disable the field by simply setting the sensitive attribute of that handle to true or false respectively.
The following procedure 'getFieldHandle' should be defined as a local procedure in the viewer object:
PROCEDURE getFieldHandle :
/*------------------------------------------------------------- */
/* Purpose: Returns the field handle given its name */
/*------------------------------------------------------------- */
DEFINE INPUT PARAMETER pcFieldName AS CHARACTER NO-UNDO.
DEFINE OUTPUT PARAMETER phFieldHandle AS HANDLE NO-UNDO.
DEFINE VARIABLE hHandleVariable AS HANDLE NO-UNDO.
ASSIGN
hHandleVariable = FRAME {&FRAME-NAME}:HANDLE
hHandleVariable = hHandleVariable:FIRST-CHILD.
IF hHandleVariable:TYPE = "FIELD-GROUP" THEN
phFieldHandle = hHandleVariable:FIRST-CHILD.
REPEAT WHILE VALID-HANDLE( phFieldHandle ):
IF phFieldHandle:TYPE = "fill-in" AND phFieldHandle:NAME =
pcFieldName THEN:
RETURN.
phFieldHandle = phFieldHandle:NEXT-SIBLING.
END.
END PROCEDURE.
The above procedure may be called from anywhere in the application. The following button trigger demonstrates how to use the above trigger to disable the Cust-Num field. If no field with that name exists in the Smart Viewer Object, then a message to that effect will be issued:
ON CHOOSE OF BUTTON-1 IN FRAME F-Main /* Button 1 */
DO:
DEFINE VARIABLE hFieldHandle AS HANDLE NO-UNDO.
DEFINE VARIABLE cFieldName AS CHARACTER NO-UNDO.
ASSIGN
cFieldName = "Cust-Num".
RUN getFieldHandle IN h_vcust8 (INPUT cFieldName , OUTPUT
hFieldHandle).
IF VALID-HANDLE(hFieldHandle) THEN
hFieldHandle:SENSITIVE = FALSE.
ELSE
MESSAGE "There is no field named " + cFieldName
VIEW-AS ALERT-BOX.
END.