Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Hide a property

Posted on 2004-10-07
7
Medium Priority
?
223 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 2000 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

Technology Partners: 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!

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

971 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