API:Vcl.Controls.TMargins.AssignTo

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

procedure AssignTo(Dest: TPersistent); override;

C++

virtual void __fastcall AssignTo(System::Classes::TPersistent* Dest);

Properties

Type Visibility Source Unit Parent
procedure
function
protected
Vcl.Controls.pas
Vcl.Controls.hpp
Vcl.Controls TMargins

Description

Copies the properties of an object to a destination object.

Vcl.Controls.TMargins.AssignTo inherits from System.Classes.TPersistent.AssignTo. All content below this line refers to System.Classes.TPersistent.AssignTo.

Copies the properties of an object to a destination object.

Override the AssignTo method to extend the functionality of the Assign method of destination objects so that they handle newly created object classes. When defining a new object class, override the Assign method for every existing object class that should be able to copy its properties to the new class. Override the AssignTo method for every existing class to which the new class can copy.

The Assign method of TPersistent calls AssignTo if the descendant object does not succeed in copying the properties of a source object. The AssignTo method defined by TPersistent raises an EConvertError exception.

For example, given the following code in which A and B are instance variables:

A.Assign(B); {Delphi}
A->Assign(B); // C++

if A knows how to handle B, then it does so and returns. If A doesn't know how to handle B's type, execution will trickle to the TPersistent version of Assign, which calls:

B.AssignTo(A); {Delphi}
B->AssignTo(A); // C++

If B knows how to copy to A, the assignment succeeds. Otherwise, TPersistent raises an exception.

See Also