为什么我在Form中发布的三个属性
    myname
    yourname
    myColor
在Object Inspector中看不到呢?是Delphi的问题还是我程序写的不对?
unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, 
  Forms, Dialogs, ExtCtrls, StdCtrls, ComCtrls, Buttons;type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Edit1: TEdit;
    BitBtn1: TBitBtn;
    procedure Button1Click(Sender: TObject);  private
    Fmyname:string;
    Fyourname:string;
    FmyColor:Tcolor;
    function Getmyname: string;
    procedure Setmyname(value:string);
    procedure Setcolor(value:Tcolor);
  protected    { Private declarations }
  public    { Public declarations }
  published
    property youname:string read Fyourname;
    property myname:string read Getmyname write setmyname;
    property myColor: TColor read FmyColor write SetColor default clBtnHighlight;
    { published declarations here }  end;var
  Form1: TForm1;implementation{$R *.dfm}
{$M+}{ TForm1 }function TForm1.Getmyname: string;
begin
Result := Fmyname;
end;procedure TForm1.Setcolor(value: Tcolor);
begin
  if Value <> Color then
    FmyColor := Value;
end;procedure TForm1.Setmyname(value: string);
begin
  if Value <> myname then
    Fmyname := Value;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
  form1.Fmyname:='myname_test';
  edit1.Text:=myname;
end;end.

解决方案 »

  1.   

    应该是delphi的问题,
    不过呢,也没关系,这并不影响你在程序中调用他们。
      

  2.   

    第一:
    property youname:string read Fyourname;
    只读的属性在属性面板上是看不到的
    可以改成:
    property youname:string read Fyourname write setyouname;procedure TForm1.setyouname(value:string);
    begin
    //什么也不干
    end;
    第二:也是主要原因,窗体的发布有些特殊
    需要把TForm1发到包中编译注册才行
    Delphi5和6有些不同,6的有点麻烦,所以这里告诉你Delphi6的
    新建一个注册的单元
    内容如下
    unit MY_Form_Reg;interfaceuses
      你的窗体单元, DesignIntf, DesignEditors;procedure Register;implementationprocedure Register;begin
      RegisterCustomModule(你的窗体类名, TCustomModule);
    end;end.新建一个包选中Require点击ADD。
    添加Delphi目录下的bin目录中的designide.dcp文件。
    然后编译安装。
    最后在窗体上点击右键选“添加到仓库”添到一个仓库内比如“Form”
    新建工程,选File|New|在你的仓库中选你添加的窗体。试试看
    累死我了
      

  3.   

    TO: wr960204(武稀松) 
    佩服另外帮你补充一下
    将下面多加一些单元
    uses
      你的窗体单元, DesignIntf, DesignEditors;
    改写为:
      你的窗体单元, Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, DesignIntf, DesignEditors, DB, DBTables, DBCtrls;很感谢又长了知识,谢谢!