Working with Properties
The interfaces of ABBYY FineReader Engine objects have various properties and methods. In general, properties represent information about an object, whereas methods represent actions an object can take.
C# and Visual Basic users are familiar with the notion of property. For a C++ user, a property is a pair of methods (get and put for read-write properties) or a single get method (for read-only properties). However, the "Native COM support" featured by Microsoft C++ makes the way the properties are handled more like the one used in C#.
The ABBYY FineReader Engine properties may be of the following types:
IDL | C++ | C# | Visual Basic .NET |
---|---|---|---|
VARIANT_BOOL (VARIANT_TRUE or VARIANT_FALSE) | VARIANT_BOOL (VARIANT_TRUE or VARIANT_FALSE) | bool (true or false) | Boolean (True or False) |
int | int | int | Integer |
double | double | double | Double |
BSTR, a pointer to Unicode string. Zero value specifies an empty string. | BSTR | string | String |
__int64 | __int64 | Int64 | Int64 |
HANDLE* | void* | IntPtr | IntPtr |
IUnknown-derived interface | IUnknown-derived interface | object | Object |
enum | enum | enum | Enum |
See the details of working with different types of properties below:
Working with simple properties
Working with string properties
Working with object properties
Working with read-only object properties
Certain ABBYY FineReader Engine objects (for example, ILayout::Blocks) have read-only object properties. This does not mean that such properties cannot be changed, this only means that they cannot be changed by directly replacing the object property with another object, because "put" method is not supported. However, you can change the sub-properties of these objects.
In raw C++, if you want to change such a property, you need to pass a reference to the property object to a new variable, and then use this variable to change it. Below you can see a C++ sample for the ILayout::Blocks property which is represented by a read-only collection:
// We assume that a page has been already opened ILayout* pLayout = 0; ILayoutBlocks* pLayoutBlocks = 0; int blockIndex = 0; // Receive the layout from the previously opened FRPage pFRPage->get_Layout( &pLayout ); // The pLayoutBlocks variable receives a reference to the blocks collection from Layout pLayout->get_Blocks( &pLayoutBlocks ); // Remove an element from the block collection pLayoutBlocks->DeleteAt( blockIndex ); // Work with modified layout ... // Release the objects pLayoutBlocks->Release(); pLayout->Release();
9/17/2024 3:14:40 PM