Delphi 与 DirectX 之 DelphiX(6): 让 TDXImageList 和常规 VCL 交互使用
2009-01-12 22:58
441 查看
本例测试了两个问题:
1、其他 VCL 加载的图片能否给 TDXImageList 使用;
2、TDXImageList 中的图片能否给其他 VCL 使用.
例子中先用 TPicture 加载了图片, 然后给 TDXImageList;
然后把图片绘制在了窗体上, 而非 TDXDraw 中.
继续了解点 TDXImageList:
TDXImageList 控件只有两个属性: DXDraw 和 Items.
DXDraw 是图像的目的地, 很好理解;
Items 是一个对象集合: TPictureCollection;
TPictureCollection 集合中包含的是一组 TPictureCollectionItem 对象;
TPictureCollectionItem 对象有 Picture 属性, 这和其他 VCL 中的 TPicture 兼容!
本例用到了 TPictureCollectionItem 对象, 测试效果图:
![](http://images.cnblogs.com/cnblogs_com/del/171104/o_091124.gif)
代码文件:
1、其他 VCL 加载的图片能否给 TDXImageList 使用;
2、TDXImageList 中的图片能否给其他 VCL 使用.
例子中先用 TPicture 加载了图片, 然后给 TDXImageList;
然后把图片绘制在了窗体上, 而非 TDXDraw 中.
继续了解点 TDXImageList:
TDXImageList 控件只有两个属性: DXDraw 和 Items.
DXDraw 是图像的目的地, 很好理解;
Items 是一个对象集合: TPictureCollection;
TPictureCollection 集合中包含的是一组 TPictureCollectionItem 对象;
TPictureCollectionItem 对象有 Picture 属性, 这和其他 VCL 中的 TPicture 兼容!
本例用到了 TPictureCollectionItem 对象, 测试效果图:
![](http://images.cnblogs.com/cnblogs_com/del/171104/o_091124.gif)
代码文件:
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DXDraws, StdCtrls; type TForm1 = class(TForm) DXImageList1: TDXImageList; Button1: TButton; Button2: TButton; procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} {借用其他 VCL 控件加载图片} procedure TForm1.FormCreate(Sender: TObject); var pic: TPicture; begin pic := TPicture.Create; pic.LoadFromFile('c:\Temp\Test.bmp'); DXImageList1.Items.Add; DXImageList1.Items[0].Picture.Assign(pic); pic.Free; end; {这个代码貌似简单, 但代码提示不好} procedure TForm1.Button1Click(Sender: TObject); begin Self.Refresh; Self.Canvas.Draw(0, 0, DXImageList1.Items[0].Picture.Graphic); end; {使用 TPictureCollectionItem 对象中转一下, 写起来更顺手} procedure TForm1.Button2Click(Sender: TObject); var picItem: TPictureCollectionItem; begin Self.Refresh; picItem := DXImageList1.Items[0]; Self.Canvas.StretchDraw(ClientRect, picItem.Picture.Graphic); end; end.
相关文章推荐
- Delphi 与 DirectX 之 DelphiX(7): 给 TDXImageList 加载图片的最后方案
- Delphi 与 DirectX 之 DelphiX(5): 初识 TDXImageList
- 如何在Delphi TImageList 中使用 透明 png 图标
- 如何在Delphi TImageList 中使用 透明 png 图标
- Delphi中GDI+和ImageList使用的正确姿势
- Delphi 与 DirectX 之 DelphiX(26): TDIB 的主要载体 - TDXPaintBox
- C#中ListView和ImageList配合使用
- Delphi 与 DirectX 之 DelphiX(68): TDIB.DoNovaEffect();
- Delphi 与 DirectX 之 DelphiX(69): TDIB.Greyscale();
- Delphi 与 DirectX 之 DelphiX(78): TDIB.AntialiasedLine();
- Delphi 与 DirectX 之 DelphiX(89): TDIB.DrawAlphaMask();
- Delphi 与 DirectX 之 DelphiX(90): TDIB.DrawMorphed();
- [Android初级]关于使用universal-image-loader加载imagelist出现图片闪烁的问题
- Delphi 与 DirectX 之 DelphiX(10): TPictureCollectionItem.StretchDraw - 绘制到指定矩形
- Delphi 与 DirectX 之 DelphiX(30): TDIB.AddGradiantNoise();
- Delphi 与 DirectX 之 DelphiX(34): TDIB.Lightness();
- Delphi 与 DirectX 之 DelphiX(42): TDIB.GaussianBlur();
- delphi 使用image动态加载图片时的错误提醒
- 原文标题:How to use transparent PNG icons with Delphi ImageList
- 翻譯Borland® Delphi® 2005使用 VCL for .NET移植到 .NET(3)