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 TWriter


Treats unformatted data as if it were the value of a published property, and writes it directly to a memory stream.

DefineBinaryProperty is called internally by the DefineProperties method of an object that has data it needs to store. DefineProperties takes a generic filer object as its parameter.

For writing binary data DefineProperties takes a TWriter object and then calls its DefineBinaryProperty method. DefineBinaryProperty writes the property's name and its data, but only if the HasData parameter is true. Otherwise it does nothing.

The Name parameter specifies the name of the "fake" property to be written to 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 TStreamProc type is the type of the ReadData and WriteData parameters. It is the method-pointer type that points to a procedure (defined in the storing object) that reads or writes a binary representation of the object's data directly to or from the stream passed as its Stream parameter. For TWriter the ReadData parameter is ignored.

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

Defined binary properties are quite rare. Persistent objects that store graphics as binary data are the most common use of filer objects to store and retrieve that data. More commonly, objects use the DefineProperty method. The difference between DefineBinaryProperty and DefineProperty is that with DefineBinaryProperty the component reads or writes the binary property directly to or from a memory stream, rather than going through a filer object.

Note: Streamable objects that are descended from TPersistent inherit a DefineProperties method, however DefineProperties does not do anything until TComponent. It is TComponent's DefineProperties method that calls the writer's DefineBinaryProperty when writing out binary data.

See Also