组件中的Delphi PNG图像集合
今天我的问题是关于在组件中创建PNG图像的集合。 我发现一个按钮接受PNG图像作为gliph,但它使用由图像的四种状态组成的PNG图像,如下所示:组件中的Delphi PNG图像集合,delphi,png,delphi-xe7,Delphi,Png,Delphi Xe7,今天我的问题是关于在组件中创建PNG图像的集合。 我发现一个按钮接受PNG图像作为gliph,但它使用由图像的四种状态组成的PNG图像,如下所示: ... public FPngImgEnabled: TPngImage; FPngImgDisabled: TPngImage; FPngImgDown: TPngImage; FPngImgOver: TPngImage; FDown: Boolean; Constructor Create
...
public
FPngImgEnabled: TPngImage;
FPngImgDisabled: TPngImage;
FPngImgDown: TPngImage;
FPngImgOver: TPngImage;
FDown: Boolean;
Constructor Create(AOwner: TComponent); override;
Destructor Destroy; override;
procedure Paint; override;
published
property PngImgEnabled: TPngImage read FPngImgEnabled write SetPngImgEnabled;
property PngImgDisabled: TPngImage read FPngImgDisabled write SetPngImgDisabled;
property PngImgDown: TPngImage read FPngImgDown write SetPngImgDown;
property PngImgOver: TPngImage read FPngImgOver write SetPngImgOver;
...
我修改了组件,使用了四个不同的图像,每个图像对应一个状态。因此,我的组件如下所示:
...
public
FPngImgEnabled: TPngImage;
FPngImgDisabled: TPngImage;
FPngImgDown: TPngImage;
FPngImgOver: TPngImage;
FDown: Boolean;
Constructor Create(AOwner: TComponent); override;
Destructor Destroy; override;
procedure Paint; override;
published
property PngImgEnabled: TPngImage read FPngImgEnabled write SetPngImgEnabled;
property PngImgDisabled: TPngImage read FPngImgDisabled write SetPngImgDisabled;
property PngImgDown: TPngImage read FPngImgDown write SetPngImgDown;
property PngImgOver: TPngImage read FPngImgOver write SetPngImgOver;
...
这样我就有了一个包含四个PNG图像的组件,然后用于SetPng。。。程序。我想知道是否有一种方法可以使用四幅PNG图像的集合;类似于“TPNGImagesList”的东西,用于将图像集中在一个地方 我想你需要这样的东西:
type
TImgType = (itEnabled, itDisabled, itDown, itOver);
...
protected
procedure SetImg(Index: TImgType; Value: TPngImage);
function GetImg(Index: TImgType): TPngImage;
public
FImages: TList<TPngImage>;
FDown: Boolean;
Constructor Create(AOwner: TComponent); override;
Destructor Destroy; override;
procedure Paint; override;
published
property Image[Index:TImgType]: TPngImage read GetImg write SetImg;
property PngImgEnabled: TPngImage index itEnabled read GetImg write SetImg;
property PngImgDisabled: TPngImage index itDisabled read GetImg write SetImg;
property PngImgDown: TPngImage index itDown read GetImg write SetImg;
property PngImgOver: TPngImage index itOver read GetImg write SetImg;
...
类型
TImgType=(itEnabled、itDisabled、itDown、itOver);
...
受保护的
程序设置IMG(索引:TImgType;值:TPngImage);
函数GetImg(索引:TImgType):TPngImage;
公众的
图像:t列表;
FDown:布尔型;
构造函数创建(AOwner:TComponent);推翻
毁灭者毁灭;推翻
程序漆;推翻
出版
属性图像[索引:TImgType]:TPngImage read GetImg write SetImg;
属性PngImgEnabled:TPngImage index itEnabled read GetImg write SetImg;
属性PngImgDisabled:TPngImage index itDisabled read GetImg write SetImg;
属性PngImgDown:TPngImage index itDown read GetImg write SetImg;
属性PngImgOver:TPngImage index itOver read GetImg write SetImg;
...
TImageList有什么问题?TImageList中包含TPngImageList。也许这符合你的需要。可能还有一个现成的按钮,我还没有检查。附带:TPNGImageList也有什么问题?顺便问一下,哪个德尔福版本?哪个德尔福版本?如果您可以访问泛型,为什么不使用它呢?创建一个类型TImageState=(isEnabled、isDisabled、isDown、isOver)
,然后使用TObjectDictionary
。另外,字典可以拥有图像对象并自行释放它们。我使用的Delphi版本是XE7