Object Controls
Object Enhanced Controls  
  Prior Next
 

The control property 'ObjectID is used to associate an Object with a control in order to create a Object Enhanced Control.   By setting this control property to the handle of an existing object, all subsequent property references and control directives will be checked against the property and methods that the object provides.

Example:

A simple object to enhance a GRID control

0010 DEF CLASS "grid"
0020 LOCAL _CTLNO
0030 FUNCTION GETVALUE$(COL,ROW)
0040 ENTER C,R
0050 LET _CTLNO'COLUMN=C
0060 LET _CTLNO'ROW=R
0070 RETURN _CTLNO'VALUE$
0080 FUNCTION SETVALUE(COL,ROW,VALUE$)
0090 ENTER C,R,V$
0100 LET _CTLNO'COLUMN=C
0110 LET _CTLNO'ROW=R
0120 LET _CTLNO'VALUE$=V$
0130 RETURN 1
0140 FUNCTION WRITE(COL,ROW,VALUE$)
0150 ENTER C,R,V$
0160 SETTRACE PRINT "Add c="+STR(C)+" r="+STR(R)+" v="+V$
0170 GRID WRITE _CTLNO,C,R,V$
0180 RETURN 1
0190 END DEF
0200 ON_CREATE:
0210 ENTER CTLNO
0220 LET _CTLNO=CTLNO
0230 LET _CTLNO'OBJECTID=_OBJ
0240 RETURN

Once this object is instantiated, it can be assigned to the Grid control 'ObjectId property at which point all property requests will be filtered through the object.

GRD_NO = 10

GRID GRD_NO,@(40,4,30,15)
TheObj = NEW("GRID", GRD_NO)

For the purposes of this example, the Object attaches itself to the control passed in on the NEW function.   This is not required; instead, the application could simply have created the control, then the object and linked the Object to the control by setting 'ObjectId

Once the above logic is executed the application can then issue calls to GRD_NO'GetValue $() and GRD_NO'SetValue ( ) to access the grid values.   In addition any GRID WRITE directives applied to GRD_NO will invoke the method WRITE within the object.



*Note*

When a control is removed from the system and 'ObjectID is non-zero, the Object it identifies will be automatically de-referenced (dropped).



  Prior Next