Solved

Hide a property

Posted on 2004-10-07
7
212 Views
Last Modified: 2010-05-18
How can I hide one of my property ? I moved to public area, but in this case don't save my settings. Just when I let it into published my vcl save parameters to dfm file.

What to do to have it hidden but to store my parameters ?
0
Comment
Question by:ginsonic
  • 3
  • 2
  • 2
7 Comments
 
LVL 7

Expert Comment

by:LRHGuy
ID: 12251778
In your component, add:

private
   fYourPropertyBool:boolean;
protected
    procedure DefineProperties(Filer:TFiler);
      override;


Then make:

procedure Comp.DefineProperties(Filer:TFiler);
begin
  inherited DefineProperties(Filer); { allow base classes to define properties }
  Filer.DefineProperty('YourPropertyName'',True,LoadProperty_YourPropertyBoll,StoreProperty_YourPropertyBool,True);
end;

procedure Comp.LoadProperty_YourPropertyBool(Reader:TReader);
begin
  fYourPropertyBool:=Reader.ReadBoolean;
end;

procedure Comp.StoreProperty_YourPropertyBool(Writer:TWriter);
begin
  Writer.WriteBoolean(fYourPropertyBool);
end;


fYourPropertyBool just happens to be a boolean property. Make whatever you need!

0
 

Expert Comment

by:joncmora
ID: 12255496
I don't see the reason why you want to do this.

How can that property be assigned a value at design time when it's not published? IMO, the purpose of the DFM file is to store (non-default) values set at design time. Other than that, you have to assign your values in code.
0
 
LVL 7

Expert Comment

by:LRHGuy
ID: 12255512
I sometimes do this to store a state variable related to but not directly addressable by a user definable property. For example, if it's using an internally generated bitmap, or one the user supplied.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Expert Comment

by:joncmora
ID: 12255529
I see. Now I think I know what ginsonic is trying to achieve.
0
 
LVL 9

Author Comment

by:ginsonic
ID: 12256011
My property is a TCollection not a boolean. What to do ?

I wish to hide it because I use my own editor when double click on vcl.
0
 
LVL 7

Accepted Solution

by:
LRHGuy earned 500 total points
ID: 12263672
It's the same setup, you'll just have to save the collection, item by item, in the save routine (and the load routine)

procedure Comp.LoadProperty_YourProperty(Reader:TReader);
begin
// load your collection here
  Reader.ReadCollection(MyCollection);
end;

procedure Comp.StoreProperty_YourProperty(Writer:TWriter);
begin
// save your collection here
  Writer.WriteCollection(MyCollection);
end;

The ReadCollection and WriteCollection will call Read/WriteProperties() for each item in the list.

Note that you'll have to have each of the individual fields of the collection items defined as property in the DefineProperties method.
0
 
LVL 9

Author Comment

by:ginsonic
ID: 12265268
LRHGuy, I use same code untill now. For defineProperties I use:

procedure TmyVcl.DefineProperties(Filer: TFiler);
begin
  inherited DefineProperties(Filer);
  Filer.DefineProperty('MyCollection', LoadProperty, StoreProperty, FMyCollection.Count > 0);
end;

Can you tell me more, maybe codes, for defining the fields of  my  collection?
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

746 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

16 Experts available now in Live!

Get 1:1 Help Now