首页 > 其他分享 >delphi的public 与 published

delphi的public 与 published

时间:2023-04-17 19:38:16浏览次数:33  
标签:delphi public class members published type properties types


published如果属性含有下标,会不能编译通过,而public则是可以的.
属性要声明在published中,才可以显示到属性察看器中,这个是published的最大用途,published一般用于组件编程中,而不常用于应用程序中.

Published members have the same visibility as public members. The difference is that runtime type information (RTTI) is generated for published members. RTTI allows an application to query the fields and properties of an object dynamically and to locate its methods. RTTI is used to access the values of properties when saving and loading form files, to display properties in the Object Inspector, and to associate specific methods (called event handlers) with specific properties (called events). 

 Published properties are restricted to certain data types. Ordinal, string, class, interface, and method-pointer types can be published. So can set types, provided the upper and lower bounds of the base type have ordinal values between 0 and 31. (In other words, the set must fit in a byte, word, or double word.) Any real type except Real48 can be published. Properties of an array type (as distinct from array properties, discussed below) cannot be published. 

 Some properties, although publishable, are not fully supported by the streaming system. These include properties of record types, array properties of all publishable types, and properties of enumerated types that include anonymous values. If you publish a property of this kind, the Object Inspector won't display it correctly, nor will the property's value be preserved when objects are streamed to disk. 

 All methods are publishable, but a class cannot publish two or more overloaded methods with the same name. Fields can be published only if they are of a class or interface type. 

 A class cannot have published members unless it is compiled in the {$M+} state or descends from a class compiled in the {$M+} state. Most classes with published members derive from TPersistent, which is compiled in the {$M+} state, so it is seldom necessary to use the $M directive.


标签:delphi,public,class,members,published,type,properties,types
From: https://blog.51cto.com/u_16076050/6196079

相关文章

  • Delphi的字节对齐和简单string结构
    procedureTForm1.Button1Click(Sender:TObject);typeTTest=recordsAccount:string[31];//如果不加Packed30和31是相同的大小虽然是相同的,如果网络编程,传递后转换,Delphi是识别不出来的,会出现越界问题。sChrName:string[15];sUserAddr:string[15];nSessionID:......
  • Delphi类里面的方法和类型定义不影响创建实例的大小
    unitUnit1;interfaceusesWindows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms,Dialogs,StdCtrls;typeTForm1=class(TForm)Button1:TButton;procedureButton1Click(Sender:TObject);private{Privatedeclarations}public{Pub......
  • C++访问控制public private
    #include<iostream>classA{public:std::stringhead;private:std::stringbody;};intmain(){Aa;a.head="888";a.body="999";return0;}报错结果main.cpp:Infunction‘intmain()’:main.c......
  • delphi FastReport 从流(数据库)中加载和保存报表
    FastReport从流(数据库)中加载和保存报表属性和方法TfrxReport.LoadFromStreamprocedureLoadFromStream(Stream:TStream);从流中加载报表。参数Stream来源流。TfrxReport.SaveToStreamprocedureSaveToStream(Stream:TStream);将报表保存到流中。参数Stream来源......
  • Delphi FDMemTable内存表用法及简单操作函数封装(转)
    在某些场景下当轻量级的应用需要在内存中缓存数量比较多且字段比较多的高频使用数据时。以前我都是采用Ini或直接使用sqlite数据库。JSON也试过基本无法或很难实现需要的功能,因为当涉及某一同类型对象多字段多列时不通过遍历基本无法直接取到或修改数据。这样就导致了效率的低下。......
  • Navicat常见错误怎么处理(Rsa Public Key not Find、Generate First a serial、No All
    一:下载一键提取软件提取码:rtce1.Navicat数据库管理工具:NavicatDBeaver数据库管理工具:可以代替Navicat2.NavicatKeygenPatch:激活工具二:安装激活1.安装Navicat:直接下一步即可安装NavicatKeygenPatch:安装好后即可打开使用2.断网、关闭杀毒软件和本地防火墙3.......
  • delphi 播放GIF动画
    useGIFImgprocedureTForm1.Button1Click(Sender:TObject);varpic_path:string;beginpic_path:=ExtractFilePath(ParamStr(0))+'img\gif\loading.gif';image1.Picture.LoadFromFile(pic_path);//AnimationSpeed设定动画速度,值越大,速度越快TGIFImage(......
  • delphi 函数提示与注释
    效果是在IDE里输入函数名称后,在下方出现你对这个函数的注释内容:  源码:  参考地址:https://docwiki.embarcadero.com/RADStudio/Sydney/en/XML_Documentation_Comments以上内来源:Delphi研习社②群@球球......
  • delphi 如何给自开发的组件设置图标?
    经过其他老师指点,自己摸索,发现如何实现,现说明如下,供大家参考。一、建立图标文件1、建立一个24X24的256色BMP格式文件。2、文件命名为该组件的名称。二、建立资源文件:Project→Resource and Images,点击Add将BMP格式图标文件加入,Resource Identifiler 设为组件的名称......
  • delphi入门-控制台console application
    1programProject1;2usesWindows;3begin4MessageBox(0,PChar('Ok!'),PChar('Title'),0);5end.programProject1;{$APPTYPECONSOLE}varstr:string;beginWriteln('请输入:');Readln(str);Writeln('你输入的是:&#......