See the details of working with different types of properties below:
Working with simple properties
Working with simple properties
We will use the Boolean property to describe how simple properties are used. This property is described in the type library as follows:A Visual Basic user handles this property as follows:A C++ user, on the other hand, uses two methods to work with this property. These methods have get_ and put_ prefixes. The respective C++ code should look as follows:However, the Native COM support makes the procedure simpler, and the respective code should look like this:If the type library only defines the “get” method for a property, this property is called read-only. Its value cannot be changed by the user, it may only be accessed for “reading.”
Working with string properties
Working with string properties
Working with string properties is very similar to working with simple properties, but has its own specifics. A C++ user working with string properties must free the strings that are passed to set-methods, and also those that are returned by get-methods. However, this is done automatically in Visual Basic and in C++ with the Native COM support. Suppose MyObject also supports a string property called Name. This property is described in the type library as follows:A C++ user works with this property like this:For Visual Basic this may be rewritten:
Working with object properties
Working with object properties
A C++ user will say that the parameters of “get” methods of “Object” properties are pointers to an object’s interface pointer. As the interfaces of the objects are derived from IUnknown, they may be passed as IUnknown pointers to the properties or methods, which use objects of several types as input or output parameters (you may, however, get the interface you need by calling the QueryInterface method).There are two different types of “put” methods for object properties — clear put, described by the propput keyword in the type library (the object is copied in this case); and put by reference, described by the propputref keyword in the type library (only a pointer to an existing object’s interface is stored in the property in this case). A property may support only one of these put methods; most of ABBYY FlexiCapture SDK object properties clear put. In Visual Basic put by reference is performed using the Set statement, while clear put is performed without this keyword.Suppose again the MyObject object supports MyObjectProperty property that refers to an object of MyChildObject type.The same property is accessed as follows in Visual Basic:A C++ user will write this code as follows:Note that in C++ you should call the Release method for an object got via a property. The Native COM support calls AddRef and Release methods automatically using auto pointers.
