Solved

Hide a property

Posted on 2004-10-07
7
214 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

863 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

28 Experts available now in Live!

Get 1:1 Help Now