Class: cObject

Properties  Events  Methods    Index of Classes

The fundamental class from which all classes are derived



Library: Common (Windows and Web Application) Class Library

Package: none (class defined in runtime)


cObject is the ultimate base class. It contains only the interfaces required to support basic DataFlex object behaviors. Those standard behaviors consist of:

Sub-classes and objects may be created based on cObject using standard syntax. For example:

This creates a sub-class based on cObject and creates an object based on this sub-class

Class cMyInfoClass is a cObject
      Procedure Construct_Object 
           Forward Send Construct_Object
           Property String psMyInfo1
           Property String psMyInfo2

Object oMyInfo is a cMyInfoClass
      Set psMyInfo1 to "hi"
      Set psMyInfo2 to "there"

Below is an alternate method for creating on object based on the sub-class

Get Create U_cMyInfoClass to hoInfo
Set psMyInfo1 of hoInfo to "hi"
Set psMyInfo2 of hoInfo to "there"

In this example an object is created based on cObject and interfaces (in this case properties) are defined for this instance

Object oMyInfo is a cObject
      Property String psMyInfo1 "hi"
      Property String psMyInfo2 "there"

Object Delegation

By default, the delegation_mode of cObject is delegate_to_parent, which means that messages not understood by this object will delegate the parent and attempt to resolve the message there. When creating classes and objects based on cObject you may decide to disable delegation by setting the property to no_delegation. If you have created a class or object that does not need automatic delegation (and you will find that this is often the case), setting delegation_mode to no_delegation creates a class that is much easier to debug. Messages that are not understood are reported as errors, instead of delegating where they might be improperly understood. Even if delegation is turned off you can always explicitly delegate a message by using the delegate command. This often makes your intention clearer.

Note:Two private methods exist in cObject, Set Focus_mode and Set Size. If either of these methods is sent to a cObject, the object will intentionally return an error. This was added for backward compatibility considerations. These are not messages you should ever send to a non-UI object but the old class hierarchy might have required this. These errors are there to provide you with a warning that they should be removed.