Solved

Streaming Published Properties

Posted on 2002-06-29
2
211 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

734 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