Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Hide a property

Posted on 2004-10-07
7
Medium Priority
?
221 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
Independent Software Vendors: 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 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

Independent Software Vendors: 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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

704 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