我有一个 TPersistent 定义如下:
TGlyph = class(TPersistent)
private
FOwner: TControl;
FLayout: TGlyphAlignment;
FVisible: Boolean;
FImageIndex: Integer;
FImages: TImageList;
..............
protected
procedure Invalidate;
public
constructor Create(AOwner: TControl);
destructor Destroy; override;
.............
published
property ImageIndex: Integer read FImageIndex write SetImageIndex default -1;
property Images: TImageList read FImages write SetImages;
.............
end;
是否必须有一个将 nil 值分配给 FImages 字段的通知程序,例如您用于 TComponent 的那种?
procedure TGlyph.Notification(AComponent: TComponent; Operation: TOperation);
begin
inherited;
if (Operation = opRemove) and (AComponent = FImages) then
begin
FImages.OnChange := nil;
FImages := nil;
Invalidate;
end;
end;
如果可以,这个程序应该怎么写?
谢谢你,恩佐