小编El *_*blo的帖子

负属性默认值似乎不起作用

当我安装组件时,我查看了对象检查器,其值为StoppingCount0!我需要值为-1。在我的代码中,任何高于 -1 的值都会在该数字处停止 for 循环过程。

default对负数不起作用?

unit myUnit;

interface

uses
  System.SysUtils, System.Classes;

type
  TmyComponent = class(TComponent)
  private
    { Private declarations }
    FStoppingCount: integer;

  protected
    { Protected declarations }
    procedure ProcessIT();

  public
    { Public declarations }

  published
    { Published declarations }

    property StoppingCount: integer read FStoppingCount write FStoppingCount default -1;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('myComponent', [TmyComponent]);
end;

procedure TmyComponent.ProcessIT();
begin
  for I := 0 to 1000 do
  begin
    DoSomething();
    if FStoppingCount = I then break; …
Run Code Online (Sandbox Code Playgroud)

delphi default numbers properties

2
推荐指数
1
解决办法
94
查看次数

标签 统计

default ×1

delphi ×1

numbers ×1

properties ×1