差不多,只不过PUBLISHED属性就是出现在Object Inspector中的可视属性,
PUBLISHED是DELPHI特有的,VC中没有这个概念
PUBLISHED是DELPHI特有的,VC中没有这个概念
解决方案 »
- Delphi TreeView
- 用程序能识别打开的Access数据库的字段数据类型吗?????
- 知道IP地址,怎么读取该机器的文件
- 散分, 庆祝奥运
- 请问谁知道函数后面跟的Sender,Self这样的参数怎么用?
- 菜鸟问题,如何设置相对路径
- 插入一个表的同时更新其他表
- 调试:关于监视表达式的值:watch list
- delphi数据库是怎样连接的?(新手)急!
- 通过TNMFTP控件,怎么判断FTP服务器是否已经存在某目录??
- 我指定一个目录为themes,怎么查询themes目录下的子目录中的*.ini文件。但我并不知道themes下到底有多少个子目录,这些子目录中最少有一个需要的文件。如何才能进入这些子目录查询*.ini文件?怎么办?代码?
- 有个目录查询的问题,请帮助我,谢谢。
Published: 能在属性编辑器里看到;
就这点区别.
Published是缺省的关键字!
在published申明的变量的可见性和public的一样,都可以为其他的单元所使用
但他们的区别在于published的运行期类型信息不同,一个published的变量不但
可以在运行期间改变,而且可以直接在设计期间(Object Inspector)进行设计
只要相应的方法,实际上published中的变量都是delphi工具的接口
为什么在ObjectInspector中看不到呢?如果能看到,在哪里能看到?难道,还要声明成Property才可以吗?如果是这样,那么Published的变量和Procedure
又有什么意义呢...问题也许很foolish,大家不要介意,当我是个傻菜鸟好了。
Procedure aaa() 和 Variant IntegerTest1。
看来区别不是那么简单...~unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
published
IntegerTest2: Integer;
Button1: TButton;
Procedure aaa();
private
{ Private declarations }
public
IntegerTest1: Integer;
Procedure bbb();
{ Public declarations }
end;var
Form1: TForm1;implementationProcedure TForm1.aaa();
Begin
showmessage('aaa');
End;Procedure TForm1.bbb();
Begin
showmessage('bbb');
End;{$R *.DFM}end.
是不是published中不能声明普通变量,只能声明类的对象?
但Procedure却又可以放在Published中又试着将Button1:TButton放到Public中,执行出错。"Class TButton not found"
改回到Published,可以。
???是不是可视化组件只能声明为Published?
并且注意有关键字:property IntegerTest2: Integer;
如果想在Object Inspector看到你的 integerTest2
你还要写相应的write ,read方法; private
{ Private declarations }
fIntegerTest2 : integer;
function GetIntegerTest2:integer;
procedure SetIntegerTest2(Value:integer);
public
procedure aaa();
procedure bbb();
IntegerTest1: Integer;
{ Public declarations }
published
IntegerTest2: Integer;
read GetIntegerTest2
write SetIntegerTest2;
end;
public不能用名字来引用,而published可以。如你可以用methodAddress以名字得到一个published的方法的地址而进行调用。
总的说来,最明显的差别是:published的东东可以在Object Inspector中看见,能保存到流中及DFM文件中,而public只是运行时的。published的变量和方法虽然在Object Inspector中看不到,但一样可以用名字来引用。