Board index » delphi » Need Help on Property Editor

Need Help on Property Editor

Hi,
for a Mathematics-Comp I would like to add Variable Names and their Values
in the Objectinspector. The Vars are hold in a TLIST and the Items itself
are  of
Type TVar= Record
            Name: String[10];
            Value: Extended;
           end;
I'm thinking to make a property Editor with a Stringgrid allowing to
enter/edit the Var Names and the Values.
Problem: I don't know where to start, all the examples I have available
for property Editors are either for Images or simple Values, not for
String + Values.
Can someone point me into the right direction please?
Many Thanks
Georg.
email: georg...@cuci.nl  (My return address is intentionally invalid;
delete ".Remove-This-Spawm-Blocker" for real address)

 

Re:Need Help on Property Editor


Quote
On Fri, 29 Aug 1997 15:05:01 GMT, n...@junk.mail (Ray Lischner) wrote:
>On Tue, 26 Aug 1997 13:22:31 GMT, georg...@cuci.nl. (Georg Dabkiewicz)
>wrote:

[deleted]

Quote

>Ray Konopka's book, Designing Custom Delphi Components has a good
>introduction to writing property editors. For the full details, see
>Secrets of Delphi 2.
>--
>Ray Lischner (http://www.tempest-sw.com/)
>Author of "Hidden Paths of Delphi 3: Experts, Wizards, and the Open Tools API"

hello,
I have Secrets of Delphi 2 in front( i don't have R. konopka's book) of me,
sorry it doesn't make the things much clearer for me.
Up to now my Component can popup the PropertyEditor,
i copy the Components TList items into a Temp TList of the property Editor
and display the Data's I have set in the Components Constructor.
So far so good,
Now the Problems:
if I add a new Record I have to do something like
   ...
   New(AnotherRecord);
   AnotherRecord^.Name:= 'foo';
   AnotherRecord^.Value:= 4711;
   editor.Templist.add(AnotherRecord);
    ....
  and after closing the editor I think I must store back the
 modified editor.Templist somehow into the components
 property TList.  ( 1. how to do that ?)

 2. where do i dispose 'AnotherRecord'  ?
 3. AFAIK  AnotherRecord is just a pointer which is now
    hopefully stored in editor.Templist and if 1. is answered
    also stored in Component property of TLIST.
    To what will it point if 'AnotherRecord' is disposed? Or if
    I don't dispose it I get Memory Leak?
4. Can the problems be bypassed if The RecordStructure is changed
   to something like
    Type
      TVarClass = Class
        Name: String[10];
        Value: Extended;
      end;
Hopefully someone can answer some of the questions.
TIA Georg.
email: georg...@cuci.nl  (My return address is intentionally invalid;
delete ".Remove-This-Spawm-Blocker" for real address)

Re:Need Help on Property Editor


On Fri, 29 Aug 1997 19:33:55 GMT, georg...@cuci.nl (Georg Dabkiewicz)
wrote:

Quote
>if I add a new Record I have to do something like
>   ...
>   New(AnotherRecord);
>   AnotherRecord^.Name:= 'foo';
>   AnotherRecord^.Value:= 4711;
>   editor.Templist.add(AnotherRecord);
>    ....
>  and after closing the editor I think I must store back the
> modified editor.Templist somehow into the components
> property TList.  ( 1. how to do that ?)

Write a method that copies information from one list to another.

Quote
> 2. where do i dispose 'AnotherRecord'  ?

When you free the list.

Quote
> 3. AFAIK  AnotherRecord is just a pointer which is now
>    hopefully stored in editor.Templist and if 1. is answered
>    also stored in Component property of TLIST.
>    To what will it point if 'AnotherRecord' is disposed? Or if
>    I don't dispose it I get Memory Leak?

Your copy method should copy the records in the list, too. When you
free the list, free all the records in the list. This is simplest if
you write a class that manages the list contents for you. Use
TS_OwnerList as a base class.

Quote
>4. Can the problems be bypassed if The RecordStructure is changed
>   to something like
>    Type
>      TVarClass = Class
>        Name: String[10];
>        Value: Extended;
>      end;
>Hopefully someone can answer some of the questions.

You might want to use classes instead of records, but it changes
little. You still need to allocate and free the memory for the
individual items in the list. Using a class that inherits from
TPersistent makes it easier to store the information in a DFM file.
--
Ray Lischner (http://www.tempest-sw.com/)
Author of "Hidden Paths of Delphi 3: Experts, Wizards, and the Open Tools API"

Re:Need Help on Property Editor


Quote
On Sat, 30 Aug 1997 15:15:58 GMT, n...@junk.mail (Ray Lischner) wrote:
>[deleted]

Hi again,
it is more or less working now. I can make changes to the component's list
in my property Editor and all changes are copied back to the Component's
List.
But now a new proplem:
As soon as i run a testapplication using the component in the IDE, then
again the components constructor is called, creates a new List and all the
changes I've done with the property editor are lost.
How can i avoid this? Can I eleminate this by using the procedure loaded
somehow?
TIA Georg.
email: georg...@cuci.nl  (My return address is intentionally invalid;
delete ".Remove-This-Spawm-Blocker" for real address)

Other Threads