Solved

Hide a property

Posted on 2004-10-07
7
220 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
[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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month11 days, 10 hours left to enroll

623 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