我的环境:Windows 7 Pro(32位)上的RadStudio XE4。
Difference between property and function or procedures
在上面的Q和A中,有回复说 “更具体地说,如果使用Delphi IDE进行编程,您将看到已发布的属性(-y + ies)将显示在Object Inspector中。”
我试过了。
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs;
type
TForm1 = class(TForm)
private
FSampleProp1: Integer;
function GetSampleProp1(): Integer;
procedure SetSampleProp1(val: Integer);
{ Private declaration }
published
{ Private declaration }
property SampleProp1: Integer read GetSampleProp1 write SetSampleProp1;
end;
我希望在Object Inspector的“property”选项卡中有“SampleProp1”。但我没有那个。
相反,我在[Delphi Class Exploroer]“窗口中有了”SampleProp1“。
我在Object Inspector中拥有已发布的属性是不正确的吗?
答案 0 :(得分:4)
Object Inspector仅显示在设计时包中向IDE注册的属性。你还没有这样做。
因此,您可以将表单包含在设计时包中,并通过调用RegisterCustomModule
进行注册。但是,如果您的表单在您的应用程序中处于活动开发状态,这可能会非常不方便。您可能会发现自己在设计时包和应用程序之间反复失去同步。
应用表单范围的行为更改的另一种方法是创建一个可以放在表单上的非可视组件。这种方法的优点是您可以将表单更改为您的内容,而不是与您的设计时组件不同步。