저는 Delphi vcl 구성 요소를 만들고 있는데, 구성 요소 클래스에는 TImagelist를 선택할 수있는 'images'속성이 있습니다.Delphi 구성 요소 디자인 - 하위 구성 요소의 구성 요소에서 속성 가져 오기
구성 요소 클래스에는 자체적으로 imageindex 속성이있는 하위 속성 'buttons'이 있습니다.
저는 imagelist에서 버튼의 이미지를 선택할 수 있도록 imageindex 속성에 대한 구성 요소 편집기를 작성했습니다. 전에 다른 구성 요소에서이 작업을 수행했지만 지금 직면하고있는 문제는 'buttons'하위 클래스 이벤트의 이벤트에서 기본 클래스의 images 속성을 가져와야한다는 것입니다.
그래서, 구성 요소의 기본 클래스는 다음과 같은 속성이 있습니다
버튼 클래스는이 속성이property Buttons: TFlexButtons read FButtons write FButtons;
property Images: TCustomImageList read FImages write SetImages;
:
property ImageIndex: TImageIndex read FImageIndex write SetImageIndex default -1;
내가를 붙일 수 속성에 대한 별도의 단위의 속성 편집기를 등록을 , 이미지를 선택하려면이 이벤트에서 구성 요소의 baseclass에서 imagelist를 가져와야합니다.이 하위 속성에서이 속성을 어떻게 가져 옵니까?
function TImageIndexProperty.GetImageListAt(Index: Integer): TCustomImageList;
var APersistent: TPersistent;
begin
APersistent := GetComponent(Index);
if APersistent is TFlexButton then
Result := ??????????.Images //how do i refer to the images property of the component here?
else
Result := nil;
end;
모든 클래스는 :
TFlexButton = class(TCollectionItem)
private
FWidth: Word;
FCaption: string;
FHeight: Word;
FImageIndex: TImageIndex;
procedure SetCaption(const Value: string);
procedure SetHeight(const Value: Word);
procedure SetWidth(const Value: Word);
procedure SetImageIndex(const Value: TImageIndex);
public
constructor Create(AOwner: TComponent);
destructor Destroy; override;
published
property Caption: string read FCaption write SetCaption;
property Height: Word read FHeight write SetHeight;
property Width: Word read FWidth write SetWidth;
property ImageIndex: TImageIndex read FImageIndex write SetImageIndex default -1;
end;
TFlexButtons = class(TCollection)
private
function GetItem(Index: Integer): TFlexButton;
public
function Add: TFlexButton;
property Item[index: Integer]: TFlexButton read GetItem;
end;
TFlexButtonGroupBox = class(TcxGroupBox)
private
FDataLink: TFieldDataLink;
FAbout: string;
FAlignment: TAlignment;
FEnabled: Boolean;
FButtons: TFlexButtons;
FImages: TCustomImageList;
FSql: TStrings;
FAutosize: Boolean;
procedure SetAlignment(const Value: TAlignment);
function GetDataField: string;
function GetDataSource: TdataSource;
procedure SetDataField(const Value: string);
procedure SetDataSource(const Value: TdataSource);
procedure DataChange(Sender: TObject);
procedure SetEnabled(const Value: Boolean);
procedure SetImages(const Value: TCustomImageList);
procedure SetSql(const Value: TStrings);
procedure SetAutosize(const Value: Boolean);
protected
public
procedure Loaded; override;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property DataField: string read GetDataField write SetDataField;
property DataSource: TdataSource read GetDataSource write SetDataSource;
property Enabled: Boolean read FEnabled write SetEnabled;
property Autosize: Boolean read FAutosize write SetAutosize;
property About: string read FAbout write FAbout;
property Buttons: TFlexButtons read FButtons write FButtons;
property Images: TCustomImageList read FImages write SetImages;
property Alignment: TAlignment read FAlignment write SetAlignment;
property Sql: TStrings read FSql write SetSql;
end;
감사합니다, 이것은 잘 작동하는 것 같다 지금은 시스템을 이해합니다. –