Welcome, Guest
Username: Password: Remember me
Discussions for CodeTyphon Object Pascal Programming Language
  • Page:
  • 1

TOPIC:

Custom component and RTTI ImageIndex property 4 years 4 months ago #14138

  • Roman
  • Roman's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 88
  • Thank you received: 0
Hello!
I just can’t understand what needs to be done with the ImageIndex property in my own component, so that in the property editor instead of the image number a drop-down list with images is displayed.
TMyComp = class(TComponent)
 { ... any methods and fields ...}
published
  property ImageList : TCustomImageList read FImageList write SetImageList;
  property ImageIndex : TImageIndex read FImageIndex write SetImageIndex default -1; // IDE Property Editor show only numbers, not images!
end;


How to make it like this:
Attachments:

Please Log in or Create an account to join the conversation.

Last edit: by Roman.

Custom component and RTTI ImageIndex property 4 years 4 months ago #14150

  • Roman
  • Roman's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 88
  • Thank you received: 0
I helped myself :P

So that in the IDE property editor of custom component it is possible to select ImageIndex by image from associated ImageList, you need to register your own editor of the Image Index property:
type
  TMyImageIndexEditor = class(TImageIndexPropertyEditor )
  protected
    function GetImageList: TCustomImageList; override;
  end;

  function TMyImageIndexEditor.GetImageList: TCustomImageList;
  begin
    Result := (GetComponent(0) as TMyComponent).FImageList
  end;

procedure Register;
begin
  RegisterComponents('My Tool Tab',[TMyComponent]);
  RegisterPropertyEditor(TypeInfo(TImageIndex), TMyComponent, 'ImageIndex', TMyImageIndexEditor);
end;

Important: property names must be correct, i.e. Images and ImageIndex, as written in RegisterPropertyEditor.

Please Log in or Create an account to join the conversation.

  • Page:
  • 1