To store and load unpublished properties, you must first create a method to store your property value and another to load your property value. You have two choices:
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;
void __fastcall TSampleComponent::LoadCompProperty(TReader *Reader) { if (Reader->ReadBoolean()) MyCompProperty = Reader->ReadComponent(NULL); } void __fastcall TSampleComponent::StoreCompProperty(TWriter *Writer) { if (MyCompProperty) { Writer->WriteBoolean(true); Writer->WriteComponent(MyCompProperty); } else Writer->WriteBoolean(false); }
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|