Result := ControlClass.Create(MainForm);
with Result do
begin
Parent := MainForm;
Name := ControlName;
SetBounds(X, Y, W, H);
Visible := True;
end;
end;
The
CreateControl
function requires a class-reference parameter to tell it what kind of control to create. It uses
this parameter to call the class's constructor. Because class-type identifiers denote class-reference values, a call to
CreateControl
can specify the identifier of the class to create an instance of. For example,
CreateControl(TEdit, 'Edit1', 10, 10, 100, 20);
Constructors called using class references are usually virtual. The constructor implementation activated by the call
depends on the runtime type of the class reference.
Dostları ilə paylaş: