Solved

Streaming Published Properties

Posted on 2002-06-29
2
210 Views
Last Modified: 2010-04-04
I'm experimenting with saving and loading components using Delphi's streaming mechanism. I've declared a new class with the following declaration :

TOmxSourceID   = type integer;
TOmxClassID    = type integer;

TOmxSourceClass = class(TPersistent)
private
  FClass: TOmxClassID;
  FSource: TOmxSourceID;
published
  property Source : TOmxSourceID read FSource write FSource;
  property SourceClass : TOmxClassID read FClass write FClass;
end;

I have then declared a new panel component with TomxSourceClass as a published property

TOmxDataEntryPanel = class(TPanel)
private
  FSourceClass: TOmxSourceClass;
public
  constructor Create(AOwner : TComponent); override;
published
  property SourceClass : TOmxSourceClass read FSourceClass;
end;

constructor TOmxDataEntryPanel.Create(AOwner: TComponent);
begin
  inherited;
  FSourceClass := TOmxSourceClass.Create;
  FSourceClass.Source := -1;
  FSourceClass.SourceClass  := -1;
end;

The SourceClass.Source and SourceClass.SourceClass properties can be set OK but when the form is saved to a database and reloaded the properties have defaulted back to -1. I don't think the problem is with the save/load routines as all the other properties are saved ok.

Could it be the declarations of TomxSourceID and TomxClassID?

Thanks

Jo
0
Comment
Question by:nnbbb09
2 Comments
 
LVL 3

Author Comment

by:nnbbb09
ID: 7120369

I've managed to answer it myself. The problem was due to SourceClass being declared as a readonly property of TomxPanel. It should read

TOmxDataEntryPanel = class(TPanel)
private
 FSourceClass: TOmxSourceClass;
public
 constructor Create(AOwner : TComponent); override;
published
 property SourceClass : TOmxSourceClass read FSourceClass write FSourceClass;
end;
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 7120627
Points refunded and question closed, per Asker request.

Netminder
CS Moderator
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question