unit MyEdit;interfaceuses
  SysUtils, Classes, Controls;type
  TMyEdit = class(TWinControl)
  private
    { Private declarations }
    FLabel:TLabel;
    FButton:TButton;
    FEdit:TEdit;
  protected
    { Protected declarations }
  public
    { Public declarations }
    constructor Create(AOwner:TComponent);override;
    destructor Destroy;override;
    procedure CreateWnd; override;
  published
    { Published declarations }
    property Width default 120;
    property Height default 80;
  end;procedure Register;implementationprocedure Register;
begin
  RegisterComponents('Samples', [TMyEdit]);
end;constructor TMyEdit.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  Width:=120;
  Height:=80;
  FLabel:=TLabel.Create(Self);
  FEdit:=TEdit.Create(Self);
  FButton:=TButton.Create(Self);end;
procedure TMyEdit.CreateWnd ;
begin
  inherited CreateWnd;
  FLabel.Parent:=Self;
  FLabel.Left:=5;
  FLabel.Top:=5;
  FEdit.Parent:=Self;
  FEdit.Left:=5;
  FEdit.Top:=30;
  FButton.Parent:=Self;
  FButton.Left:=5;
  FButton.TOP:=55;end;
destructor TMyEdit.Destroy;
begin
  FLabel.Free;
  FEdit.Free;
  FButton.Free;
  inherited Destroy;
end;end.
这是一个自定义控件,安装的时候提示有问题:
undeclared identifier 'TLabel'
undeclared identifier 'TButton'
undeclared identifier 'TEdit'
这是我在书上抄的程序,刚学Delhi也没装过控件,请大侠多多指教

解决方案 »

  1.   

    uses
      SysUtils, Classes, Controls, StdCtrls;
    //引用单元StdCtrls就行了.
      

  2.   

    我加了单元StdCtrls后,能够安装成功。但是,使用的时候又报错,报错和之前安装报错一样,请问是为什么啊?
    使用的程序是:
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, MyEdit;type
      TForm1 = class(TForm)
        MyEdit1: TMyEdit;
        MyEdit2: TMyEdit;
        MyEdit3: TMyEdit;
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
        procedure Edit1Click(Sender:TObject);
        procedure Edit2Click(Sender:TObject);
        procedure Edit3Click(Sender:TObject);
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);begin
    MyEdit1.FButton.Caption:='姓名';
    MyEdit1.FLabel.Caption:='姓名';
    MyEdit1.FButton.OnClick:=Edit1Click;
    MyEdit2.FButton.Caption:='性别';
    MyEdit2.FLabel.Caption:='性别';
    MyEdit2.FButton.OnClick:=Edit2Click;
    MyEdit3.FButton.Caption:='年龄';
    MyEdit3.FLabel.Caption:='年龄';
    MyEdit3.FButton.OnClick:=Edit3Click;
    end;
    procedure TForm1.Edit1Click(Sender:Tobject);
    begin
    ShowMessage('你是'+MyEdit1.FEdit.Text);
    end;procedure TForm1.Edit2Click(Sender:Tobject);
    begin
    ShowMessage('你是'+MyEdit2.FEdit.Text+'性');
    end;procedure TForm1.Edit3Click(Sender:Tobject);
    begin
    ShowMessage('你是'+MyEdit3.FEdit.Text='岁');
    end;end.报错:
    undeclared identifier 'FButton'
    undeclared identifier 'FLabel'
    undeclared identifier 'FButton'
    undeclared identifier 'FButton'
    undeclared identifier 'FLabel'



    就是有FButton,FLabel,和FEdit出现的全都会报错
      

  3.   

    你没有将定义的这些控件以属性的形式publish出去,外部当然不能访问了
      

  4.   

    你好,能够说下具体怎么发布出去吗?我直接在publish下加了:property FButton;
    property FLabel;
    property FEdit;但是,报错:FButton,FLabel,FEdit重复定义。