unit PNetClassRefVCtor;

interface

uses
  Borland.Win32.Windows,
  Borland.Win32.Messages,
  Borland.Delphi.SysUtils,
  Borland.Delphi.Variants,
  Borland.Delphi.Classes,
  Borland.Vcl.Graphics,
  Borland.Vcl.Controls,
  Borland.Vcl.Forms,
  Borland.Vcl.Dialogs,
  Borland.Vcl.StdCtrls,
  Borland.Vcl.ExtCtrls;

type
  TForm1 = class(TForm)
  private
    { Private declarations }
		procedure InitializeControls;
  public
    { Public declarations }
		constructor Create(AOwner: TComponent); override;
    function CreateControl(classref: TControlClass;
      const cName: String; const X, Y, W, H: Integer): TControl;
  end;

var
  Form1: TForm1;

implementation


constructor TForm1.Create(AOwner: TComponent);
begin
	inherited;
	InitializeControls;
end;

procedure TForm1.InitializeControls;
begin
  CreateControl(TEdit, 'TEdit1', 10, 10, 100, 30);
  CreateControl(TButton, 'TButton1', 150, 10, 100, 30);
  CreateControl(TListBox, 'TListBox1', 50, 80, 200, 200);
  CreateControl(TMemo, 'TMemo1', 350, 80, 200, 200);
end;

function TForm1.CreateControl(classref: TControlClass;
  const cName: String; const X, Y, W, H: Integer): TControl;
begin
  Result := classref.Create(Self);
  Result.Name := cName;
  Result.Parent := Self;
  Result.Left := X;
  Result.Top := Y;
  Result.Width := W;
  Result.Height := H;
  Result.Visible := True;
end;

end.
