• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 486
  • Last Modified:

property Editor..to edit strings....

i have a code to get the properties of my component...
procedure TFrame4.PropertyEditor(Root: TComponent);
  procedure MakePick(Item :TItemProp; PropInfo: PPropInfo);
  var
    i: integer;
    TypeData: PTypeData;
  begin
    Item.PickList.Clear;
    Item.EditStyle := esPickList;
    TypeData := GetTypeData(PropInfo^.PropType^);
    for i := TypeData^.MinValue to TypeData^.MaxValue do
      Item.PickList.Add(GetEnumName(PropInfo^.PropType^,i));

    Item.ReadOnly := True;
  end;
var
  PropInfo : PPropInfo;
  i : integer;
begin
  for i := 0 to ValueEditor.Strings.Count -1 do
  begin
    PropInfo := GetPropInfo(Root,
                            ValueEditor.Strings.Names[i]);
    if Assigned(PropInfo) then
    case PropInfo^.PropType^.Kind of
      tkEnumeration:
        MakePick(ValueEditor.ItemProps[i],PropInfo);
    end;
  end;
end;

this work well..only for values lilke TRUE|FALSE...how can i do to edit properties like TSTRINGS...or TFONT, TCOLOR...?

thanks...
0
ThoseBug
Asked:
ThoseBug
  • 2
1 Solution
 
shaneholmesCommented:
You need a class property editor

sholmes
0
 
shaneholmesCommented:
Off the top of my head -

type

  TNewProp = class(TPersistent)
    ...
  end;


  TNewComponent = class(TComponent)
  published
    property NewProp: TNewProp read XXX write XXX;
  end;


  TNewPropProperty = class(TClassProperty)
    procedure Edit; override;
  end;


procedure TNewPropProperty.Edit;
var
  ThisValue: TNewProp;
begin
  if (GetComponent(0) is TNewComponent) then
    ThisValue := (GetComponent(0) as TNewComponent).NewProp;
end;

....................


There are many articles & pages on the internet related to this subject....

do a search uisng Googles Groups on "Delphi Class property editor"

http://groups-beta.google.com/groups?q=delphi+%2B+class+property+editor&qt_s=Search+Groups

sholmes
0
 
cwwkieCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup topic area:
   Accept: shaneholmes {http:#13716226}

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

cwwkie
EE Cleanup Volunteer
0

Featured Post

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!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now