delphi的面向对象编程

                            如何编写自己的组件:如何添加属性显示在object inspect中
unit customcontrol1;

interface

uses
  Windows, Messages, SysUtils, Classes, Controls;

type
  Tcustomcontrol1 = class(Tcustomcontrol)
  private
    { Private declarations }
    FintegerProp:integer;
    Fauthor:string;
    FcharProp:char;
  protected
    { Protected declarations }
  public
    { Public declarations }
  published      //此处的属性显示在 object inspector  中
  property integerprop:integer read FintegerProp write FintegerProp default 100;
  property author:string read Fauthor write Fauthor ;
  property charprop:char read FcharProp write FcharProp ;
  {格式:
     property 属性名:类型 read ... write .... default ;其中default 属性为可选项
    { Published declarations }
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Standard', [Tcustomcontrol1]);
end;

end.
                                

查看回复