How to remove a property from a child component

I created the TListView descendent component ... It functions flawlessly, but I am wondering if it is possible to remove the TListView property that I do not want in the offspring. Properties that I do not want to appear in the object inspector are LargeImages, RowSelect, ShowColumnHeader, ShowWorkAreas, ViewStyle, OwnerData, OnData and OnDataFind. A descendant has only one viewstyle vsIcon.

This is the interface part of the component:

  TImageEnListView = class(TListView)
  private
    FImageList: TImageList;
    FImageIndex: integer;
    FStringList: TStringList;
    FThumbnailWidth: integer;
    FThumbnailHeight: integer;
    FIconVerticalSpacing: integer;
    FIconHorzontalSpacing: integer;
    FFolder: string;
    FShadowedThumbnail: boolean;
    FShowCaptions: boolean;
    FShowTips: boolean;
    FBackgroundWorker: TBackgroundWorker;
    FTaskDialog: TTaskDialog;
    procedure BackgroundWorkerWork(Worker: TBackgroundWorker);
    { Event after threading is complete }
    procedure BackgroundWorkerWorkComplete(Worker: TBackgroundWorker; Cancelled: Boolean);
    { Event for feedback to GUI }
    procedure BackgroundWorkerWorkFeedback(Worker: TBackgroundWorker; FeedbackID,
      FeedbackValue: Integer);
  public
   { Public declarations }
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    { Clears thumbnails, fileList and imageList }
    procedure ClearThumbnails;
    procedure InfoTip(Sender: TObject; Item: TListItem; var InfoTip: string);
    procedure Data(Sender: TObject; Item: TListItem);
    procedure DataFind(Sender: TObject; Find: TItemFind; const FindString: string;
      const FindPosition: TPoint; FindData: Pointer; StartIndex: Integer; Direction:
      TSearchDirection;
      Wrap: Boolean; var Index: Integer);
    procedure FillItems;
    property BackgroundWorker: TBackgroundWorker read FBackgroundWorker;
  published
    { Published declarations }
    property Folder: string read FFolder write FFolder;
    property FileList: TStringList read FStringList write FStringList;
    property ImageList: TImageList read FImageList write FImageList;
    property ThumbnailWidth: integer read FThumbnailWidth write FThumbnailWidth default 170;
    property ThumbnailHeight: integer read FThumbnailHeight write FThumbnailHeight default 120;
    property ShadowedThumbnail: boolean read FShadowedThumbnail write FShadowedThumbnail default
      True;
    property ShowTips: boolean read FShowTips write FShowTips default False;
    property ShowCaptions: boolean read FShowCaptions write FShowCaptions default True;
  end;
+2
source share
3 answers

TTCustomListView TListView , . VCL ( ComCtrls), , TListView ( TListView, , ). ( ) , :

TImageEnListView = class(TCustomListView)
... other code
published
  // Only expose some of the properties that are protected
  // in TCustomListView. Meaningless from a use standpoint,
  // but demonstrates the technique
  property Columns;
  property ColumnClick;
  property Constraints;
  property DragCursor;
  property DragKind;
  property DragMode;
  property Enabled;
  property Font;
  property FlatScrollBars;
  property FullDrag;
  property GridLines;
  property HideSelection;
end;

, TCustom, - , , , , , , , - ( , ):

type
  TMySpecialListView=class(TComponent)
  private
    FEnListView: TImageEnListView;
    function GetThumbnailHeight: Integer;
    function GetThumbnailWidth: Integer;
    procedure SetThumbnailHeight(Value: Integer);
    procedure SetThumbnailWidth(Value: Integer);
  public
    constructor Create(AOwner: TComponent); override;
  published
    property ThumbnailHeight: Integer read GetThumbnailHeight
      write SetThumbnailHeight;
    property ThumbnailWidth: Integer read GetThumbnailWidth
      write SetThumbnailWidth;
  end;

implementation

{ TMySpecialListView }

constructor TMySpecialListView.Create(AOwner: TComponent);
begin
  inherited;
  FEnhListView := TImageEnListView.Create(Self);
  FEnhListView.Parent := Self.Parent;
  // Set other properties needed like width and height. You
  // can get the ones you need from your current .dfm values
  // for a new blank form with your TImageEnListView dropped
  // on it.
end;

function TMySpecialListView.GetThumbnailHeight: Integer;
begin
  Result := FEnhListView.ThumbnailHeight;
end;

function TMySpecialListView.GetThumbnailWidth: Integer;
begin
  Result := FEnhListView.ThumbnailWidth;
end;

procedure TMySpecialListView.SetThumbnailHeight(Value: Integer);
begin
  if Value <> FEnhListView.ThumbnailHeight then
    FEnhListView.ThumbnailHeight := Value;
end;

procedure TMySpecialListView.SetThumbnailWidth(Value: Integer);
begin
  if Value <> FEnhListView.ThumbnailWidth then
    FEnhListView.ThumbnailWidth := Value;
end;
+13

, () Object Inspector - :

UnlistPublishedProperty(TImageEnListView , 'LargeImages')

UnlistPublishedProperty DesignIntf.dcu, , designide.

+2

, , , (, ) , .

, , PropertyEditor GetProperties .

0
source

All Articles