白给分的题,--简单(50分)

  • 主题发起人 主题发起人 lb_icesea79
  • 开始时间 开始时间
L

lb_icesea79

Unregistered / Unconfirmed
GUEST, unregistred user!
1.自已在定义组件的时候, 什么情况下需要重载DefineProperties呀
2。是不是组件添加数据项后就要重载Assign和AssignTo呀
 
搞明白了终于, 这分怎么回来呀
 
给大家分了得了
 
Designates methods for storing an object's unpublished data on a stream such as a form file.
指派方法,方法是用来存贮对象的未公布的数据到一个流,比如文件。

This example shows how to load and save an unpublished property whose value is a component that was created at runtime. It defines two methods, LoadCompProperty and StoreCompProperty that load or save the property value. The also defines an override for the DefineProperties method where these methods are passed to the streaming system. The DefineProperties method checks the filer抯 Ancestor property to avoid saving a property value in inherited forms.

procedure TSampleComponent.LoadCompProperty(Reader: TReader);
begin
if Reader.ReadBoolean then
MyCompProperty := Reader.ReadComponent(nil);
end;

procedure TSampleComponent.StoreCompProperty(Writer: TWriter);

begin
Writer.WriteBoolean(MyCompProperty <> nil);
if MyCompProperty <> nil then
Writer.WriteComponent(MyCompProperty);
end;

procedure TSampleComponent.DefineProperties(Filer: TFiler);

function DoWrite: Boolean;
begin
if Filer.Ancestor <> nil then { check Ancestor for an inherited value }
begin
if TSampleComponent(Filer.Ancestor).MyCompProperty = nil then
Result := MyCompProperty <> nil
else if MyCompProperty = nil or
TSampleComponent(Filer.Ancestor).MyCompProperty.Name
<> MyCompProperty.Name then
Result := True

else Result := False;
end
else { no inherited value -- check for default (nil) value }
Result := MyCompProperty <> nil;
end;
begin
inherited; { allow base classes to define properties }
Filer.DefineProperty('MyCompProperty', LoadCompProperty, StoreCompProperty, DoWrite);
end;

 
把钱分了吧,提出问题后就会不来了。
 
不要考虑了,分给我不就得了嘛,你还欠我200分呢,嘿嘿...
 
接受答案了.
 
后退
顶部