Solved

Streaming Published Properties

Posted on 2002-06-29
2
207 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
Comment Utility

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
Comment Utility
Points refunded and question closed, per Asker request.

Netminder
CS Moderator
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now