From RAD Studio API Documentation
Jump to: navigation, search


procedure DefineBinaryProperty(const Name: string;
ReadData, WriteData: TStreamProc;
HasData: Boolean); override;


virtual void __fastcall DefineBinaryProperty(const System::UnicodeString Name, TStreamProc ReadData, TStreamProc WriteData, bool HasData);


Type Visibility Source Unit Parent
System.Classes TReader


Defines binary data the reader object reads as if the data were a published property.

DefineBinaryProperty is called internally by the DefineProperties method of an object that has data it needs to store. Applications can call DefineBinaryProperty directly when overriding the DefineProperties method of a component with large custom data (like a bitmap). This is the only context in which DefineBinaryProperty (or DefineProperty) should be used.

DefineProperties takes a generic filer object as its parameter. For reading binary data, DefineProperties takes a TReader object and calls its DefineBinaryProperty method. DefineBinaryProperty then reads the property's name data and passes the data to the indicated ReadData method.

The Name parameter specifies the name of the "fake" property to be read from the stream. A "fake" property is a property that is not published, and that exists only in the code for the DefineBinaryProperty method. The Top and Left properties of a non-visual component are examples of "fake" properties. These are also called "defined properties" or "custom defined properties."

The ReadData and WriteData parameters point to a procedure (defined in the component object) that reads or writes a binary representation of the object's data directly to or from the stream passed to them in the Stream parameter. For TReader the WriteData parameter is ignored.

The HasData parameter determines at run time whether the "fake" property has data to store (write). For TReader the HasData parameter is ignored.

Defined binary properties are rare. More commonly, objects use the DefineProperty method. The difference between DefineBinaryProperty and DefineProperty is that when using DefineBinaryProperty, the component reads the binary property directly from a memory stream, rather than going through the filer object. Binary data is also harder to edit as text.

Note: Streamable objects that descend from TPersistent inherit a DefineProperties method. DefineProperties is a stub method and is only implemented in TComponent and its descendants. Therefore, it is a component's DefineProperties method that calls the reader's DefineBinaryProperty when reading binary data.

See Also