You are here: Symbol Reference > MtxBaseComp Namespace > Classes > TMtxComponent Class
MtxVec VCL
ContentsIndex
PreviousUpNext
TMtxComponent Class

Common ancestor of all components using MtxVec.

MtxBaseComp_TMtxComponent
Pascal
TMtxComponent = class(TComponent);

Most Delphi/C++Builder developers are familiar with the following methods:

  • SaveToStream
  • LoadFromStream
  • LoadFromFile
  • SaveToFile
  • Assign

 

TMtxComponent declares generic versions of these routines so that all components derived from it have all their published properties streamed, without the need to make any changes to the streaming routines. Therefore, all components derived form TMtxComponent have the capability to store their states (properties) to the stream, file or to assign from another object of the same type. The default component streaming mechanism has a bug when it comes to streaming properties with a declared default value. This has been fixed for TMtxComponent. 

The component also declares a more advanced set of streaming methods:

 

These methods set a special protected property named BlockAssign to True. This is very useful when there is a need to save only "parameters" and not the "data" of the component. The parameters will remain the same, while the "data" will be different next time and there is no point in wasting disk space by saving it. 

The BlockAssign property can be used in two ways. It can be used as a storage specifier for a published property: 

property Data: TVec read fData write SetData stored AllowStreaming; 

In this case when the BlockAssign property is True the AllowStreaming protected function will return false. The property will not be saved and consequently when the stream is loaded this property will not be set. This will affect only the SaveTemplateToStream/SaveTemplateToFile/Assign methods. 

Another approach is to allow storing the property to the stream and then explicitely check the value BlockAssign property to prevent assignment of the value. The first approach is much more elegant because it reduces the size of the "template" file. 

The value of the protected BlockAssign property is set automatically by the component. All the user is required to do is use the storage specifiers (the "stored" keyword with AllowStreaming function) for "template like" properties.

Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!